fairwire-directory-hygiene 0.0.0-stage → 0.1.0
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.
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +213 -2
- package/bin/fairwire-directory-hygiene.js +7 -0
- package/evals/cases.json +352 -0
- package/fixtures/README.md +6 -0
- package/fixtures/intl/README.md +12 -0
- package/fixtures/intl/de/objects.csv +18 -0
- package/fixtures/intl/ja/objects.csv +18 -0
- package/fixtures/objects.csv +18 -0
- package/fixtures/settings-stale.json +3 -0
- package/fixtures/settings.json +4 -0
- package/package.json +57 -4
- package/server.json +37 -0
- package/src/demo.js +19 -0
- package/src/index.js +2 -0
- package/src/logic.js +70 -0
- package/src/manifest.js +35 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kurt Francisco
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,214 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fairwire Directory Hygiene
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Directory hygiene from Active Directory or Entra exports: computer objects not seen for months, unsupported operating systems, accounts with passwords that never expire or are not required, disabled accounts still in groups, empty groups, groups with no owner and nested group loops. Drafts clean-up lists; never edits the directory.
|
|
4
|
+
|
|
5
|
+
Part of **Fairwire**, the IT and network family of [Mythos Machines](https://fair-agents.com) agents. The software is free (MIT); you pay a fixed price for the setup on your files. It reads files your IT team exports, on your own computer, and drafts notes. Every change to a live device, firewall, DNS zone, directory or cloud account stays one named person's click.
|
|
6
|
+
|
|
7
|
+
## What it checks
|
|
8
|
+
|
|
9
|
+
| Finding | What it means |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `password_not_required` | An enabled user account flagged "password not required" (it may have an empty password). |
|
|
12
|
+
| `nested_group_loop` | Groups that contain each other in a loop, which breaks access reviews and some applications. |
|
|
13
|
+
| `password_never_expires` | An enabled user account whose password never expires (low for accounts you mark as service accounts). |
|
|
14
|
+
| `unsupported_os_computer` | An enabled computer object with an operating system past its vendor end of support. |
|
|
15
|
+
| `disabled_in_groups` | A disabled account that is still a member of groups (medium when one of them is privileged). |
|
|
16
|
+
| `stale_computer` | An enabled computer object that has not logged on for longer than your limit. |
|
|
17
|
+
| `group_without_owner` | A group with no owner (managed by), so nobody reviews who is in it. |
|
|
18
|
+
| `empty_group` | A group with no members. |
|
|
19
|
+
|
|
20
|
+
Findings come back worst first (high, medium, low). A finding a named person has reviewed can be accepted as known, with a reason and a date to look again; it then moves to "Accepted as known" instead of counting as open.
|
|
21
|
+
|
|
22
|
+
## Settings
|
|
23
|
+
|
|
24
|
+
Pass a settings file with `settings`. Every setting is optional; a misspelt setting is refused by name.
|
|
25
|
+
|
|
26
|
+
| Setting | What it does |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `stale_days` | Days without a logon after which a computer counts as stale (default 90) |
|
|
29
|
+
| `unsupported_os` | Operating systems past end of support, matched as text; "*" stands for any text, and LTSC, LTSB or IoT systems are only matched by an entry that names them (default: END_OF_SUPPORT_OS as of 19 Nov 2026: Windows 2000, XP, Vista, 7, 8, 8.1 and 10, Windows 10 LTSB, Windows 11 21H2 to 23H2 and Home and Pro 24H2, Windows Server 2003, 2008 and 2012) |
|
|
30
|
+
| `privileged_groups` | Groups that grant admin rights (default Domain Admins, Enterprise Admins, Schema Admins, Administrators, Account Operators, Backup Operators) |
|
|
31
|
+
| `service_account_prefixes` | Name prefixes of service accounts, e.g. "svc-" (their non-expiring passwords are low, not medium) |
|
|
32
|
+
| `builtin_groups` | Groups that need no owner (default the built-in admin and user groups) |
|
|
33
|
+
|
|
34
|
+
## What it never does
|
|
35
|
+
|
|
36
|
+
- `directory_modify_object` is refused: Fairwire Directory Hygiene never edits, disables, moves or deletes a directory object.
|
|
37
|
+
- `directory_remove_member` is refused: Fairwire Directory Hygiene never removes anyone from a group.
|
|
38
|
+
- `directory_request_send` waits for one named person's click, even in Auto (`binding_send`).
|
|
39
|
+
- `directory_accept_learning` waits for one named person's click, even in Auto (`accept_learning`).
|
|
40
|
+
- `directory_retire_memory` waits for one named person's click, even in Auto (`accept_learning`).
|
|
41
|
+
- `directory_modify_object` waits for one named person's click, even in Auto (`production_deploy`).
|
|
42
|
+
- `directory_remove_member` waits for one named person's click, even in Auto (`revoke_access`).
|
|
43
|
+
|
|
44
|
+
<!-- generated:start -->
|
|
45
|
+
|
|
46
|
+
## A demo run
|
|
47
|
+
|
|
48
|
+
`npx -y fairwire-directory-hygiene demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
Fairwire Directory Hygiene demo (fictional data) in a temporary folder, Auto on for the draft only
|
|
52
|
+
|
|
53
|
+
▶ Check the exported files
|
|
54
|
+
status: executed decision: allow
|
|
55
|
+
17 object(s): 6 user(s), 5 computer(s), 6 group(s): 11 open finding(s), 1 high.
|
|
56
|
+
high password_not_required user
|
|
57
|
+
medium disabled_in_groups user
|
|
58
|
+
medium nested_group_loop group
|
|
59
|
+
medium password_never_expires user
|
|
60
|
+
medium unsupported_os_computer computer
|
|
61
|
+
medium unsupported_os_computer computer
|
|
62
|
+
low group_without_owner group
|
|
63
|
+
low password_never_expires user
|
|
64
|
+
low stale_computer computer
|
|
65
|
+
low stale_computer computer
|
|
66
|
+
info empty_group group
|
|
67
|
+
|
|
68
|
+
▶ Explain one finding
|
|
69
|
+
status: executed decision: allow
|
|
70
|
+
medium nested_group_loop: Groups Finance Readers > Finance Share contain each other in a loop. Fix: Break the loop by removing one of the nested memberships.
|
|
71
|
+
|
|
72
|
+
▶ Write the worklist
|
|
73
|
+
status: executed decision: allow
|
|
74
|
+
Directory hygiene written: 17 object(s): 6 user(s), 5 computer(s), 6 group(s): 11 open finding(s), 1 high.
|
|
75
|
+
|
|
76
|
+
▶ Draft the note for a person
|
|
77
|
+
status: executed decision: allow (auto)
|
|
78
|
+
cleanup list 2026-11-18 drafted with 1 open marker(s) ([TO CONFIRM identity and directory administrators]). Nothing was sent.
|
|
79
|
+
|
|
80
|
+
▶ Auto: approving it still waits for one named person
|
|
81
|
+
status: needs_approval decision: ask
|
|
82
|
+
reason: binding_send stays one-click, even in Auto
|
|
83
|
+
|
|
84
|
+
▶ The agent tries to change the live system itself
|
|
85
|
+
status: blocked decision: block
|
|
86
|
+
reason: Fairwire Directory Hygiene never edits, disables, moves or deletes a directory object.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Tools
|
|
90
|
+
|
|
91
|
+
| Tool | What it does | Policy |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `directory_check` | Review the directory export and list risky password flags, group loops, unsupported and stale computers, disabled members, ownerless and empty groups. | runs |
|
|
94
|
+
| `directory_explain` | Every finding for one user, computer or group. | runs |
|
|
95
|
+
| `directory_write_report` | Write directory-hygiene.csv (one row per finding, with blank owner and decision columns) and directory-hygiene.html into out_dir (default fairwire-out/directory). | runs |
|
|
96
|
+
| `directory_draft_cleanup_list` | Write drafts/cleanup_list-<date>.md: the open findings at or above min_severity (default medium), each with what to do, addressed to identity and directory administrators. | asks first (Auto can be opted in) |
|
|
97
|
+
| `directory_request_send` | After one named human click (even in Auto), record that the reviewed cleanup list draft is approved in cleanup_list-requests.csv. | one named click, even in Auto (`binding_send`) |
|
|
98
|
+
| `directory_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
|
|
99
|
+
| `directory_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
|
|
100
|
+
| `directory_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
|
|
101
|
+
| `directory_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
|
|
102
|
+
| `directory_modify_object` | Fairwire Directory Hygiene never edits, disables, moves or deletes a directory object. | refused |
|
|
103
|
+
| `directory_remove_member` | Fairwire Directory Hygiene never removes anyone from a group. | refused |
|
|
104
|
+
|
|
105
|
+
Any tool name not in this table is blocked, including names a model invents. `refused` tools are listed so a model can see they exist and are refused.
|
|
106
|
+
|
|
107
|
+
## Columns it reads
|
|
108
|
+
|
|
109
|
+
Table inputs can be CSV, TSV, semicolon- or pipe-separated text, Excel `.xlsx`, JSON or JSONL. Columns are matched by the agent's own name, then by the English names below, then by their names in German, French, Spanish, Portuguese, Italian, Japanese, Chinese and Korean. Dates become `YYYY-MM-DD`; amounts and counts are read with either decimal mark. Every result lists under `sources` how each file was read.
|
|
110
|
+
|
|
111
|
+
### Directory objects (`objects`)
|
|
112
|
+
|
|
113
|
+
| Column | Type | Also read as | For example, in other languages |
|
|
114
|
+
|---|---|---|---|
|
|
115
|
+
| `type` (required) | text | Type, Object Class, ObjectClass, Object Type | Typ, Type, 種類, 类型 |
|
|
116
|
+
| `name` (required) | text | Name, SamAccountName, sAMAccountName, Display Name, CN | Name, Nom, 名前, 名称 |
|
|
117
|
+
| `enabled` | text | Enabled, Account Enabled, Status | Aktiviert, Activé, 有効, 已启用 |
|
|
118
|
+
| `last_logon` | date | LastLogonDate, Last Logon, lastLogonTimestamp, Last Sign-in, ApproximateLastSignInDateTime | Letzte Anmeldung, Dernière connexion, 最終ログイン, 最后登录 |
|
|
119
|
+
| `os` | text | OperatingSystem, Operating System, OS | Betriebssystem, Système d’exploitation, OS, 操作系统 |
|
|
120
|
+
| `pwd_never_expires` | text | PasswordNeverExpires, Password Never Expires, DONT_EXPIRE_PASSWORD | - |
|
|
121
|
+
| `pwd_not_required` | text | PasswordNotRequired, Password Not Required, PASSWD_NOTREQD | - |
|
|
122
|
+
| `member_of` | text | MemberOf, Member Of, Groups | - |
|
|
123
|
+
| `members` | number | Members, Member Count, MemberCount | - |
|
|
124
|
+
| `managed_by` | text | ManagedBy, Managed By, Owner, Owners | - |
|
|
125
|
+
| `nested_groups` | text | Nested Groups, Member Groups, Group Members | - |
|
|
126
|
+
|
|
127
|
+
### Files from other countries
|
|
128
|
+
|
|
129
|
+
A German export in Windows-1252 with semicolons, `1.234,56` and `03.11.2026`, or a Japanese one in Shift_JIS with `2026/11/03`, is read the same way as the English file. [`fixtures/intl/`](fixtures/intl) has both versions of the demo data, and the eval cases `intl-de-*` and `intl-ja-*` require the same results as the English case. Columns named differently? Run `npx fairwire-directory-hygiene inspect <file>` (names and shapes only, never values) and name them in `fairwire-sources.json`:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{ "files": { "exports/devices.csv": { "columns": { "host": "Gerätename" }, "date_order": "dmy" } } }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Memory
|
|
136
|
+
|
|
137
|
+
fairwire-directory-hygiene can remember facts about your setup so the next run does not have to be told again. `directory_learn` only proposes a fact; it changes nothing until a named person accepts it with `directory_accept_learning`, which is one click even in Auto. Facts live in one hash-chained file per agent under `.fairwire/memory/`; if the chain does not verify, no fact is used. Credentials, personal identifiers and text that reads like instructions to an AI are refused. Run without memory with `--no-memory`.
|
|
138
|
+
|
|
139
|
+
| Kind | What an accepted fact changes |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `known_exception` | that finding is listed under "Accepted as known" instead of as open, until review_by (when given) has passed. |
|
|
142
|
+
| `note` | nothing (shown by recall only) |
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
fairwire-directory-hygiene memory list
|
|
146
|
+
fairwire-directory-hygiene memory accept MEM-1a2b3c4d5e6f --as "Your Name"
|
|
147
|
+
fairwire-directory-hygiene memory retire MEM-1a2b3c4d5e6f --as "Your Name" --reason "rule removed"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Install
|
|
151
|
+
|
|
152
|
+
Node 20 or newer. No other dependencies.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npx -y fairwire-directory-hygiene demo
|
|
156
|
+
npx -y fairwire-directory-hygiene mcp --root /path/to/your/files
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Claude Desktop, Cursor and other MCP hosts:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"fairwire-directory-hygiene": {
|
|
165
|
+
"command": "npx",
|
|
166
|
+
"args": [
|
|
167
|
+
"-y",
|
|
168
|
+
"fairwire-directory-hygiene",
|
|
169
|
+
"mcp",
|
|
170
|
+
"--root",
|
|
171
|
+
"/path/to/your/files"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Claude Code: `claude mcp add fairwire-directory-hygiene -- npx -y fairwire-directory-hygiene mcp --root .`, or install the `fairwire-directory-hygiene` plugin from this repository's marketplace.
|
|
179
|
+
|
|
180
|
+
## Modes and approvals
|
|
181
|
+
|
|
182
|
+
- **Review** (`--mode review`): reads and reports only.
|
|
183
|
+
- **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairwire-directory-hygiene approve <id> --as "Your Name"` (or on the local approvals page, `fairwire-directory-hygiene approvals`), and the same call is repeated.
|
|
184
|
+
- **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairwire-directory-hygiene kill`). Paying, sending, posting to a ledger or a live system and accepting a learned fact stay **one named click even in Auto**; an approval is tied to the sha256 of the reviewed draft, so a changed draft needs a new click.
|
|
185
|
+
|
|
186
|
+
## CLI
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
fairwire-directory-hygiene tools # every tool, its policy and arguments
|
|
190
|
+
fairwire-directory-hygiene sources # the columns each input is read from
|
|
191
|
+
fairwire-directory-hygiene inspect <file> # how a file would be read (names and shapes, never values)
|
|
192
|
+
fairwire-directory-hygiene call directory_check '{"objects":"<objects>"}'
|
|
193
|
+
fairwire-directory-hygiene eval # the private eval cases on the fictional fixtures
|
|
194
|
+
fairwire-directory-hygiene demo
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Audit log and data
|
|
198
|
+
|
|
199
|
+
Every call is written to `.fairwire/audit.jsonl` under the root: hash-chained JSON lines, with arguments stored as a hash, signed with an Ed25519 key when you configure one. Everything runs on your machine on files you choose. No network calls, no telemetry, no credentials. The bundled fixtures are fictional.
|
|
200
|
+
|
|
201
|
+
<!-- generated:end -->
|
|
202
|
+
|
|
203
|
+
## Limits
|
|
204
|
+
|
|
205
|
+
- Reads only the files you export and give it. It does not log in to a firewall, switch, controller, cloud console, identity provider or any other live system.
|
|
206
|
+
- Last logon dates in Active Directory replicate slowly (lastLogonTimestamp can lag by up to two weeks); stale means "probably", so disable before deleting.
|
|
207
|
+
- Thresholds are working defaults in a settings file you control; they are not a vendor rule, a requirement of any standard or a security guarantee.
|
|
208
|
+
- Results returned to the AI model have the names of people, sign-in names, e-mail addresses, phone numbers and client addresses masked. The files written here keep the real values: keep them in a secure folder.
|
|
209
|
+
- It changes nothing on a live device, firewall, DNS zone, directory or cloud account. Every change it suggests is a draft that one named person applies.
|
|
210
|
+
- Export layouts were written from knowledge of common exports and have not been tested on live customer accounts. Run `inspect` on a new export and name columns in `fairwire-sources.json` when they differ.
|
|
211
|
+
|
|
212
|
+
## Licence
|
|
213
|
+
|
|
214
|
+
MIT. Fictional data only in `fixtures/`.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { main } from 'fairwire-core';
|
|
4
|
+
import { manifest } from '../src/manifest.js';
|
|
5
|
+
import { demo } from '../src/demo.js';
|
|
6
|
+
|
|
7
|
+
main(manifest, { bin: 'fairwire-directory-hygiene', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
|
package/evals/cases.json
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "fairwire-directory-hygiene",
|
|
3
|
+
"root": "..",
|
|
4
|
+
"data_note": "Fictional directory objects in ../fixtures, as of 2026-11-18. No model is called.",
|
|
5
|
+
"cases": [
|
|
6
|
+
{
|
|
7
|
+
"id": "check-totals",
|
|
8
|
+
"tool": "directory_check",
|
|
9
|
+
"args": {
|
|
10
|
+
"objects": "fixtures/objects.csv",
|
|
11
|
+
"settings": "fixtures/settings.json",
|
|
12
|
+
"as_of": "2026-11-18"
|
|
13
|
+
},
|
|
14
|
+
"expect": {
|
|
15
|
+
"equals": {
|
|
16
|
+
"result.objects": 17,
|
|
17
|
+
"result.users": 6,
|
|
18
|
+
"result.computers": 5,
|
|
19
|
+
"result.groups": 6,
|
|
20
|
+
"result.open": 11,
|
|
21
|
+
"result.high": 1
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "every-planted-issue",
|
|
27
|
+
"tool": "directory_check",
|
|
28
|
+
"args": {
|
|
29
|
+
"objects": "fixtures/objects.csv",
|
|
30
|
+
"settings": "fixtures/settings.json",
|
|
31
|
+
"as_of": "2026-11-18"
|
|
32
|
+
},
|
|
33
|
+
"expect": {
|
|
34
|
+
"contains": [
|
|
35
|
+
"password_not_required",
|
|
36
|
+
"nested_group_loop",
|
|
37
|
+
"Finance Readers > Finance Share",
|
|
38
|
+
"password_never_expires",
|
|
39
|
+
"Service account",
|
|
40
|
+
"unsupported_os_computer",
|
|
41
|
+
"Windows Server 2012 R2",
|
|
42
|
+
"disabled_in_groups",
|
|
43
|
+
"Domain Admins",
|
|
44
|
+
"stale_computer",
|
|
45
|
+
"2026-06-20",
|
|
46
|
+
"group_without_owner",
|
|
47
|
+
"VPN Users",
|
|
48
|
+
"empty_group",
|
|
49
|
+
"Old Project"
|
|
50
|
+
],
|
|
51
|
+
"not_contains": [
|
|
52
|
+
"PC-104",
|
|
53
|
+
"PC-101"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "user-names-masked",
|
|
59
|
+
"tool": "directory_check",
|
|
60
|
+
"args": {
|
|
61
|
+
"objects": "fixtures/objects.csv",
|
|
62
|
+
"settings": "fixtures/settings.json",
|
|
63
|
+
"as_of": "2026-11-18"
|
|
64
|
+
},
|
|
65
|
+
"expect": {
|
|
66
|
+
"not_contains": [
|
|
67
|
+
"cdiaz",
|
|
68
|
+
"bkim",
|
|
69
|
+
"svc-backup"
|
|
70
|
+
],
|
|
71
|
+
"matches": [
|
|
72
|
+
"USR-[0-9a-f]{8}"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"id": "longer-stale-limit",
|
|
78
|
+
"tool": "directory_check",
|
|
79
|
+
"args": {
|
|
80
|
+
"objects": "fixtures/objects.csv",
|
|
81
|
+
"settings": "fixtures/settings-stale.json",
|
|
82
|
+
"as_of": "2026-11-18",
|
|
83
|
+
"code": "stale_computer"
|
|
84
|
+
},
|
|
85
|
+
"expect": {
|
|
86
|
+
"equals": {
|
|
87
|
+
"result.findings": 1
|
|
88
|
+
},
|
|
89
|
+
"contains": [
|
|
90
|
+
"SRV-OLD"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"id": "explain-group",
|
|
96
|
+
"tool": "directory_explain",
|
|
97
|
+
"args": {
|
|
98
|
+
"objects": "fixtures/objects.csv",
|
|
99
|
+
"settings": "fixtures/settings.json",
|
|
100
|
+
"as_of": "2026-11-18",
|
|
101
|
+
"name": "finance share"
|
|
102
|
+
},
|
|
103
|
+
"expect": {
|
|
104
|
+
"contains": [
|
|
105
|
+
"nested_group_loop"
|
|
106
|
+
],
|
|
107
|
+
"equals": {
|
|
108
|
+
"result.findings": 1
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "draft-after-approval",
|
|
114
|
+
"tool": "directory_draft_cleanup_list",
|
|
115
|
+
"approve": "Pat Example",
|
|
116
|
+
"args": {
|
|
117
|
+
"objects": "fixtures/objects.csv",
|
|
118
|
+
"settings": "fixtures/settings.json",
|
|
119
|
+
"as_of": "2026-11-18"
|
|
120
|
+
},
|
|
121
|
+
"expect": {
|
|
122
|
+
"status": "executed",
|
|
123
|
+
"contains": [
|
|
124
|
+
"Nothing was sent"
|
|
125
|
+
],
|
|
126
|
+
"equals": {
|
|
127
|
+
"result.items": 6,
|
|
128
|
+
"result.open_markers": 1
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"id": "review-mode-still-reads",
|
|
134
|
+
"tool": "directory_check",
|
|
135
|
+
"mode": "review",
|
|
136
|
+
"args": {
|
|
137
|
+
"objects": "fixtures/objects.csv",
|
|
138
|
+
"settings": "fixtures/settings.json",
|
|
139
|
+
"as_of": "2026-11-18"
|
|
140
|
+
},
|
|
141
|
+
"expect": {
|
|
142
|
+
"status": "executed",
|
|
143
|
+
"equals": {
|
|
144
|
+
"result.objects": 17,
|
|
145
|
+
"result.users": 6,
|
|
146
|
+
"result.computers": 5,
|
|
147
|
+
"result.groups": 6,
|
|
148
|
+
"result.open": 11,
|
|
149
|
+
"result.high": 1
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"generated": true
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"id": "severity-filter",
|
|
156
|
+
"tool": "directory_check",
|
|
157
|
+
"args": {
|
|
158
|
+
"objects": "fixtures/objects.csv",
|
|
159
|
+
"settings": "fixtures/settings.json",
|
|
160
|
+
"as_of": "2026-11-18",
|
|
161
|
+
"severity": "high"
|
|
162
|
+
},
|
|
163
|
+
"expect": {
|
|
164
|
+
"status": "executed",
|
|
165
|
+
"equals": {
|
|
166
|
+
"result.findings": 1
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"generated": true
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"id": "missing-argument-named",
|
|
173
|
+
"tool": "directory_check",
|
|
174
|
+
"args": {},
|
|
175
|
+
"expect": {
|
|
176
|
+
"status": "error",
|
|
177
|
+
"contains": [
|
|
178
|
+
"objects"
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
"generated": true
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"id": "file-outside-root-refused",
|
|
185
|
+
"tool": "directory_check",
|
|
186
|
+
"args": {
|
|
187
|
+
"objects": "../../../outside.csv",
|
|
188
|
+
"settings": "fixtures/settings.json",
|
|
189
|
+
"as_of": "2026-11-18"
|
|
190
|
+
},
|
|
191
|
+
"expect": {
|
|
192
|
+
"status": "error",
|
|
193
|
+
"contains": [
|
|
194
|
+
"outside"
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
"generated": true
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"id": "invented-tool-name-refused",
|
|
201
|
+
"tool": "directory_apply_every_fix_now",
|
|
202
|
+
"args": {},
|
|
203
|
+
"expect": {
|
|
204
|
+
"status": "blocked"
|
|
205
|
+
},
|
|
206
|
+
"generated": true
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"id": "write-report-writes-files",
|
|
210
|
+
"tool": "directory_write_report",
|
|
211
|
+
"args": {
|
|
212
|
+
"objects": "fixtures/objects.csv",
|
|
213
|
+
"settings": "fixtures/settings.json",
|
|
214
|
+
"as_of": "2026-11-18"
|
|
215
|
+
},
|
|
216
|
+
"expect": {
|
|
217
|
+
"status": "executed",
|
|
218
|
+
"contains": [
|
|
219
|
+
"directory-hygiene.csv",
|
|
220
|
+
"directory-hygiene.html"
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
"generated": true
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"id": "recall-memory-starts-empty",
|
|
227
|
+
"tool": "directory_recall",
|
|
228
|
+
"args": {},
|
|
229
|
+
"expect": {
|
|
230
|
+
"status": "executed",
|
|
231
|
+
"contains": [
|
|
232
|
+
"memory is empty"
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
"generated": true
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"id": "accept-learning-stays-one-click",
|
|
239
|
+
"tool": "directory_accept_learning",
|
|
240
|
+
"mode": "auto",
|
|
241
|
+
"args": {
|
|
242
|
+
"id": "MEM-000000000000",
|
|
243
|
+
"decision": "accept"
|
|
244
|
+
},
|
|
245
|
+
"expect": {
|
|
246
|
+
"status": "needs_approval"
|
|
247
|
+
},
|
|
248
|
+
"generated": true
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"id": "never-directory-modify-object",
|
|
252
|
+
"tool": "directory_modify_object",
|
|
253
|
+
"mode": "auto",
|
|
254
|
+
"args": {},
|
|
255
|
+
"expect": {
|
|
256
|
+
"status": "blocked"
|
|
257
|
+
},
|
|
258
|
+
"generated": true
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"id": "never-directory-remove-member",
|
|
262
|
+
"tool": "directory_remove_member",
|
|
263
|
+
"mode": "auto",
|
|
264
|
+
"args": {},
|
|
265
|
+
"expect": {
|
|
266
|
+
"status": "blocked"
|
|
267
|
+
},
|
|
268
|
+
"generated": true
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"id": "draft-waits-for-a-person",
|
|
272
|
+
"tool": "directory_draft_cleanup_list",
|
|
273
|
+
"args": {
|
|
274
|
+
"objects": "fixtures/objects.csv",
|
|
275
|
+
"settings": "fixtures/settings.json",
|
|
276
|
+
"as_of": "2026-11-18"
|
|
277
|
+
},
|
|
278
|
+
"expect": {
|
|
279
|
+
"status": "needs_approval",
|
|
280
|
+
"decision": "ask"
|
|
281
|
+
},
|
|
282
|
+
"generated": true
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"id": "review-mode-drafts-nothing",
|
|
286
|
+
"tool": "directory_draft_cleanup_list",
|
|
287
|
+
"mode": "review",
|
|
288
|
+
"args": {
|
|
289
|
+
"objects": "fixtures/objects.csv",
|
|
290
|
+
"settings": "fixtures/settings.json",
|
|
291
|
+
"as_of": "2026-11-18"
|
|
292
|
+
},
|
|
293
|
+
"expect": {
|
|
294
|
+
"status": "blocked"
|
|
295
|
+
},
|
|
296
|
+
"generated": true
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"id": "request-stays-one-click",
|
|
300
|
+
"tool": "directory_request_send",
|
|
301
|
+
"mode": "auto",
|
|
302
|
+
"args": {
|
|
303
|
+
"draft": "fixtures/README.md",
|
|
304
|
+
"draft_sha256": "0000000000000000000000000000000000000000000000000000000000000000"
|
|
305
|
+
},
|
|
306
|
+
"expect": {
|
|
307
|
+
"status": "needs_approval"
|
|
308
|
+
},
|
|
309
|
+
"generated": true
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"id": "intl-de-check-totals",
|
|
313
|
+
"tool": "directory_check",
|
|
314
|
+
"args": {
|
|
315
|
+
"objects": "fixtures/intl/de/objects.csv",
|
|
316
|
+
"settings": "fixtures/settings.json",
|
|
317
|
+
"as_of": "2026-11-18"
|
|
318
|
+
},
|
|
319
|
+
"expect": {
|
|
320
|
+
"equals": {
|
|
321
|
+
"result.objects": 17,
|
|
322
|
+
"result.users": 6,
|
|
323
|
+
"result.computers": 5,
|
|
324
|
+
"result.groups": 6,
|
|
325
|
+
"result.open": 11,
|
|
326
|
+
"result.high": 1
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"note": "German export of the same data (fixtures/intl/de); must match the English case \"check-totals\"."
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"id": "intl-ja-check-totals",
|
|
333
|
+
"tool": "directory_check",
|
|
334
|
+
"args": {
|
|
335
|
+
"objects": "fixtures/intl/ja/objects.csv",
|
|
336
|
+
"settings": "fixtures/settings.json",
|
|
337
|
+
"as_of": "2026-11-18"
|
|
338
|
+
},
|
|
339
|
+
"expect": {
|
|
340
|
+
"equals": {
|
|
341
|
+
"result.objects": 17,
|
|
342
|
+
"result.users": 6,
|
|
343
|
+
"result.computers": 5,
|
|
344
|
+
"result.groups": 6,
|
|
345
|
+
"result.open": 11,
|
|
346
|
+
"result.high": 1
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
"note": "Japanese export of the same data (fixtures/intl/ja); must match the English case \"check-totals\"."
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Fairwire Directory Hygiene fixtures
|
|
2
|
+
|
|
3
|
+
Fictional directory objects (made-up user, computer and group names).
|
|
4
|
+
|
|
5
|
+
- `objects.csv`: 17 objects. cdiaz is flagged "password not required"; bkim and the svc-backup service account have passwords that never expire; dlee is disabled but still in Domain Admins; PC-102 has not logged on since June; PC-103 runs Windows 10; SRV-OLD runs Server 2012 R2 and has not logged on for a year; PC-104 is disabled (skipped); VPN Users has no owner; Old Project is empty; Finance Share and Finance Readers contain each other.
|
|
6
|
+
- `settings.json`: 90 days for stale computers; svc- marks service accounts.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Fixtures from other countries
|
|
2
|
+
|
|
3
|
+
Generated by `node scripts/make-intl-fixtures.mjs` from the English fixtures one
|
|
4
|
+
folder up. The same fictional data, written the way a local export writes it:
|
|
5
|
+
|
|
6
|
+
- `de/`: German column names, Windows-1252 text, semicolons, comma decimals
|
|
7
|
+
(1.234,56), day-first dotted dates (03.11.2026), kilograms and kilometres.
|
|
8
|
+
- `ja/`: Japanese column names, Shift_JIS text, year-first dates (2026/11/03),
|
|
9
|
+
kilograms and kilometres.
|
|
10
|
+
|
|
11
|
+
Values (names, codes, charge wording) stay in English. The eval cases
|
|
12
|
+
`intl-de-*` and `intl-ja-*` expect exactly the same results as the English case.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Typ;Vollst�ndiger Name;Aktiviert;Letzte Anmeldung;Betriebssystem;pwd_never_expires;pwd_not_required;member_of;members;managed_by;nested_groups
|
|
2
|
+
user;aortiz;True;17.11.2026;;False;False;"Staff;VPN Users";;;
|
|
3
|
+
user;bkim;True;16.11.2026;;True;False;Staff;;;
|
|
4
|
+
user;cdiaz;True;15.11.2026;;False;True;Staff;;;
|
|
5
|
+
user;svc-backup;True;18.11.2026;;True;False;Backup Operators;;;
|
|
6
|
+
user;dlee;False;01.06.2026;;False;False;"Staff;Domain Admins";;;
|
|
7
|
+
user;emoss;False;01.05.2026;;False;False;;;;
|
|
8
|
+
computer;PC-101;True;17.11.2026;Windows 11 Enterprise;;;;;;
|
|
9
|
+
computer;PC-102;True;20.06.2026;Windows 11 Enterprise;;;;;;
|
|
10
|
+
computer;PC-103;True;10.11.2026;Windows 10 Enterprise;;;;;;
|
|
11
|
+
computer;SRV-OLD;True;01.12.2025;Windows Server 2012 R2;;;;;;
|
|
12
|
+
computer;PC-104;False;01.01.2025;Windows 7 Professional;;;;;;
|
|
13
|
+
group;Staff;True;;;;;;120;HR Team;
|
|
14
|
+
group;VPN Users;True;;;;;;40;;
|
|
15
|
+
group;Old Project;True;;;;;;0;IT Team;
|
|
16
|
+
group;Finance Share;True;;;;;;12;Finance Lead;Finance Readers
|
|
17
|
+
group;Finance Readers;True;;;;;;8;Finance Lead;Finance Share
|
|
18
|
+
group;Domain Admins;True;;;;;;3;;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
���,���O,�L��,�ŏI���O�C��,�I�y���[�e�B���O�V�X�e��,pwd_never_expires,pwd_not_required,member_of,members,managed_by,nested_groups
|
|
2
|
+
user,aortiz,True,2026/11/17,,False,False,Staff;VPN Users,,,
|
|
3
|
+
user,bkim,True,2026/11/16,,True,False,Staff,,,
|
|
4
|
+
user,cdiaz,True,2026/11/15,,False,True,Staff,,,
|
|
5
|
+
user,svc-backup,True,2026/11/18,,True,False,Backup Operators,,,
|
|
6
|
+
user,dlee,False,2026/06/01,,False,False,Staff;Domain Admins,,,
|
|
7
|
+
user,emoss,False,2026/05/01,,False,False,,,,
|
|
8
|
+
computer,PC-101,True,2026/11/17,Windows 11 Enterprise,,,,,,
|
|
9
|
+
computer,PC-102,True,2026/06/20,Windows 11 Enterprise,,,,,,
|
|
10
|
+
computer,PC-103,True,2026/11/10,Windows 10 Enterprise,,,,,,
|
|
11
|
+
computer,SRV-OLD,True,2025/12/01,Windows Server 2012 R2,,,,,,
|
|
12
|
+
computer,PC-104,False,2025/01/01,Windows 7 Professional,,,,,,
|
|
13
|
+
group,Staff,True,,,,,,120,HR Team,
|
|
14
|
+
group,VPN Users,True,,,,,,40,,
|
|
15
|
+
group,Old Project,True,,,,,,0,IT Team,
|
|
16
|
+
group,Finance Share,True,,,,,,12,Finance Lead,Finance Readers
|
|
17
|
+
group,Finance Readers,True,,,,,,8,Finance Lead,Finance Share
|
|
18
|
+
group,Domain Admins,True,,,,,,3,,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type,name,enabled,last_logon,os,pwd_never_expires,pwd_not_required,member_of,members,managed_by,nested_groups
|
|
2
|
+
user,aortiz,True,2026-11-17,,False,False,Staff;VPN Users,,,
|
|
3
|
+
user,bkim,True,2026-11-16,,True,False,Staff,,,
|
|
4
|
+
user,cdiaz,True,2026-11-15,,False,True,Staff,,,
|
|
5
|
+
user,svc-backup,True,2026-11-18,,True,False,Backup Operators,,,
|
|
6
|
+
user,dlee,False,2026-06-01,,False,False,Staff;Domain Admins,,,
|
|
7
|
+
user,emoss,False,2026-05-01,,False,False,,,,
|
|
8
|
+
computer,PC-101,True,2026-11-17,Windows 11 Enterprise,,,,,,
|
|
9
|
+
computer,PC-102,True,2026-06-20,Windows 11 Enterprise,,,,,,
|
|
10
|
+
computer,PC-103,True,2026-11-10,Windows 10 Enterprise,,,,,,
|
|
11
|
+
computer,SRV-OLD,True,2025-12-01,Windows Server 2012 R2,,,,,,
|
|
12
|
+
computer,PC-104,False,2025-01-01,Windows 7 Professional,,,,,,
|
|
13
|
+
group,Staff,True,,,,,,120,HR Team,
|
|
14
|
+
group,VPN Users,True,,,,,,40,,
|
|
15
|
+
group,Old Project,True,,,,,,0,IT Team,
|
|
16
|
+
group,Finance Share,True,,,,,,12,Finance Lead,Finance Readers
|
|
17
|
+
group,Finance Readers,True,,,,,,8,Finance Lead,Finance Share
|
|
18
|
+
group,Domain Admins,True,,,,,,3,,
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fairwire-directory-hygiene",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.fpavia111-creator/fairwire-directory-hygiene",
|
|
5
|
+
"description": "Fairwire Directory Hygiene: Directory hygiene from Active Directory or Entra exports: computer objects not seen for months, unsupported operating systems, accounts with passwords that never expire or are not required, disabled accounts still in groups, empty groups, groups with no owner and nested group loops. Drafts clean-up lists; never edits the directory.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Kurt Francisco",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20"
|
|
11
|
+
},
|
|
12
|
+
"main": "src/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./src/index.js",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"fairwire-directory-hygiene": "bin/fairwire-directory-hygiene.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"bin",
|
|
23
|
+
"fixtures",
|
|
24
|
+
"evals",
|
|
25
|
+
"README.md",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"server.json"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "node scripts/run-tests.cjs",
|
|
32
|
+
"demo": "node bin/fairwire-directory-hygiene.js demo",
|
|
33
|
+
"eval": "node bin/fairwire-directory-hygiene.js eval"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"fairwire-core": "^0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/fpavia111-creator/fairwire-agents.git",
|
|
41
|
+
"directory": "packages/fairwire-directory-hygiene"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/fpavia111-creator/fairwire-agents/tree/master/packages/fairwire-directory-hygiene#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/fpavia111-creator/fairwire-agents/issues"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"mcp",
|
|
49
|
+
"mcp-server",
|
|
50
|
+
"it-operations",
|
|
51
|
+
"network",
|
|
52
|
+
"fairwire",
|
|
53
|
+
"active-directory",
|
|
54
|
+
"entra-id",
|
|
55
|
+
"directory-hygiene",
|
|
56
|
+
"stale-objects",
|
|
57
|
+
"groups"
|
|
58
|
+
]
|
|
59
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.fpavia111-creator/fairwire-directory-hygiene",
|
|
4
|
+
"title": "Fairwire Directory Hygiene",
|
|
5
|
+
"description": "Fairwire Directory Hygiene: Directory hygiene from Active Directory or Entra exports: computer…",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/fpavia111-creator/fairwire-agents",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "packages/fairwire-directory-hygiene"
|
|
11
|
+
},
|
|
12
|
+
"websiteUrl": "https://fair-agents.com/fairwire.html",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "fairwire-directory-hygiene",
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"transport": {
|
|
19
|
+
"type": "stdio"
|
|
20
|
+
},
|
|
21
|
+
"packageArguments": [
|
|
22
|
+
{
|
|
23
|
+
"type": "positional",
|
|
24
|
+
"value": "mcp"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "named",
|
|
28
|
+
"name": "--root",
|
|
29
|
+
"description": "Folder holding the exports this agent may read and write (it cannot reach outside it)",
|
|
30
|
+
"isRequired": true,
|
|
31
|
+
"format": "filepath",
|
|
32
|
+
"valueHint": "exports_folder"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
package/src/demo.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { standardDemo } from 'fairwire-core';
|
|
4
|
+
|
|
5
|
+
// The demo runs the eval case "check-totals" and the agent's draft on the fictional fixtures.
|
|
6
|
+
const cases = JSON.parse(readFileSync(new URL('../evals/cases.json', import.meta.url), 'utf8')).cases;
|
|
7
|
+
const base = cases.find((c) => c.id === 'check-totals');
|
|
8
|
+
const explain = cases.find((c) => /_explain$/.test(c.tool) && !c.expect.status);
|
|
9
|
+
const draft = cases.find((c) => /_draft_/.test(c.tool) && c.approve);
|
|
10
|
+
|
|
11
|
+
export async function demo(manifest) {
|
|
12
|
+
const refused = manifest.tools.filter((t) => (manifest.policy.rules.find((r) => r.tool === t.name) || {}).decision === 'block')[0];
|
|
13
|
+
await standardDemo(manifest, fileURLToPath(new URL('../fixtures', import.meta.url)), {
|
|
14
|
+
title: 'Fairwire Directory Hygiene demo', args: base.args,
|
|
15
|
+
explain: explain ? { label: 'Explain one finding', args: explain.args } : null,
|
|
16
|
+
draft: draft ? { label: 'Draft the note for a person', args: draft.args } : null,
|
|
17
|
+
refused: refused ? refused.name : null,
|
|
18
|
+
});
|
|
19
|
+
}
|
package/src/index.js
ADDED
package/src/logic.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Fairwire Directory Hygiene: Active Directory or Entra ID hygiene. Pure functions.
|
|
2
|
+
import { num, str, low, yes, isoDate, daysBetween, finding, END_OF_SUPPORT_OS, osPastSupport } from 'fairwire-core';
|
|
3
|
+
|
|
4
|
+
export const CHECKS = Object.freeze({
|
|
5
|
+
password_not_required: 'An enabled user account flagged "password not required" (it may have an empty password).',
|
|
6
|
+
nested_group_loop: 'Groups that contain each other in a loop, which breaks access reviews and some applications.',
|
|
7
|
+
password_never_expires: 'An enabled user account whose password never expires (low for accounts you mark as service accounts).',
|
|
8
|
+
unsupported_os_computer: 'An enabled computer object with an operating system past its vendor end of support.',
|
|
9
|
+
disabled_in_groups: 'A disabled account that is still a member of groups (medium when one of them is privileged).',
|
|
10
|
+
stale_computer: 'An enabled computer object that has not logged on for longer than your limit.',
|
|
11
|
+
group_without_owner: 'A group with no owner (managed by), so nobody reviews who is in it.',
|
|
12
|
+
empty_group: 'A group with no members.',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const OBJECT_FIELDS = Object.freeze({
|
|
16
|
+
type: { aliases: ['Type', 'Object Class', 'ObjectClass', 'Object Type'], required: true },
|
|
17
|
+
name: { aliases: ['Name', 'SamAccountName', 'sAMAccountName', 'Display Name', 'CN'], required: true },
|
|
18
|
+
enabled: { aliases: ['Enabled', 'Account Enabled', 'Status'] },
|
|
19
|
+
last_logon: { type: 'date', aliases: ['LastLogonDate', 'Last Logon', 'lastLogonTimestamp', 'Last Sign-in', 'ApproximateLastSignInDateTime'] },
|
|
20
|
+
os: { aliases: ['OperatingSystem', 'Operating System', 'OS'] },
|
|
21
|
+
pwd_never_expires: { aliases: ['PasswordNeverExpires', 'Password Never Expires', 'DONT_EXPIRE_PASSWORD'] },
|
|
22
|
+
pwd_not_required: { aliases: ['PasswordNotRequired', 'Password Not Required', 'PASSWD_NOTREQD'] },
|
|
23
|
+
member_of: { aliases: ['MemberOf', 'Member Of', 'Groups'] },
|
|
24
|
+
members: { type: 'number', aliases: ['Members', 'Member Count', 'MemberCount'] },
|
|
25
|
+
managed_by: { aliases: ['ManagedBy', 'Managed By', 'Owner', 'Owners'] },
|
|
26
|
+
nested_groups: { aliases: ['Nested Groups', 'Member Groups', 'Group Members'] },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const SETTINGS_SCHEMA = { type: 'object', additionalProperties: false, properties: {
|
|
30
|
+
stale_days: { type: 'integer', minimum: 1, description: 'Days without a logon after which a computer counts as stale (default 90)' },
|
|
31
|
+
unsupported_os: { type: 'array', items: { type: 'string' }, maxItems: 100, description: 'Operating systems past end of support, matched as text; "*" stands for any text, and LTSC, LTSB or IoT systems are only matched by an entry that names them (default: END_OF_SUPPORT_OS as of 19 Nov 2026: Windows 2000, XP, Vista, 7, 8, 8.1 and 10, Windows 10 LTSB, Windows 11 21H2 to 23H2 and Home and Pro 24H2, Windows Server 2003, 2008 and 2012)' },
|
|
32
|
+
privileged_groups: { type: 'array', items: { type: 'string' }, maxItems: 100, description: 'Groups that grant admin rights (default Domain Admins, Enterprise Admins, Schema Admins, Administrators, Account Operators, Backup Operators)' },
|
|
33
|
+
service_account_prefixes: { type: 'array', items: { type: 'string' }, maxItems: 20, description: 'Name prefixes of service accounts, e.g. "svc-" (their non-expiring passwords are low, not medium)' },
|
|
34
|
+
builtin_groups: { type: 'array', items: { type: 'string' }, maxItems: 200, description: 'Groups that need no owner (default the built-in admin and user groups)' },
|
|
35
|
+
} };
|
|
36
|
+
const PRIV = ['Domain Admins', 'Enterprise Admins', 'Schema Admins', 'Administrators', 'Account Operators', 'Backup Operators'];
|
|
37
|
+
export const DEFAULTS = Object.freeze({ stale_days: 90, unsupported_os: END_OF_SUPPORT_OS, privileged_groups: PRIV, service_account_prefixes: ['svc-', 'svc_', 'sa-'], builtin_groups: [...PRIV, 'Domain Users', 'Domain Computers', 'Domain Controllers', 'Users', 'Guests'] });
|
|
38
|
+
|
|
39
|
+
const list = (v) => str(v).split(/[;|]/).map((x) => x.replace(/^CN=([^,]+).*$/i, '$1').trim()).filter(Boolean);
|
|
40
|
+
|
|
41
|
+
export function reviewDirectory(rows, settings = {}, asOf) {
|
|
42
|
+
const s = { ...DEFAULTS, ...settings };
|
|
43
|
+
const objs = rows.filter((r) => str(r.name) && str(r.type)).map((r) => ({ type: /computer|device/i.test(str(r.type)) ? 'computer' : /group/i.test(str(r.type)) ? 'group' : 'user', name: str(r.name), enabled: yes(r.enabled) !== false, last: isoDate(r.last_logon), os: str(r.os), never: yes(r.pwd_never_expires) === true, notreq: yes(r.pwd_not_required) === true, memberOf: list(r.member_of), members: num(r.members), owner: str(r.managed_by), nested: list(r.nested_groups) }));
|
|
44
|
+
const priv = new Set(s.privileged_groups.map(low)); const builtin = new Set(s.builtin_groups.map(low));
|
|
45
|
+
const items = [];
|
|
46
|
+
for (const o of objs) {
|
|
47
|
+
if (o.type === 'computer' && o.enabled) {
|
|
48
|
+
if (o.last && asOf && daysBetween(o.last, asOf) > s.stale_days) items.push(finding('stale_computer', 'low', o.name, `Computer ${o.name} last logged on to the domain on ${o.last}.`, 'Disable it, move it to a holding OU, and delete it after a further wait if nobody asks.', { subject: 'computer' }));
|
|
49
|
+
const bad = osPastSupport(o.os, s.unsupported_os); if (bad) items.push(finding('unsupported_os_computer', 'medium', o.name, `Computer ${o.name} runs ${o.os}, which is past end of support.`, 'Upgrade or retire it; if it is already gone, clean up the object.', { subject: 'computer' }));
|
|
50
|
+
}
|
|
51
|
+
if (o.type === 'user') {
|
|
52
|
+
if (o.enabled && o.notreq) items.push(finding('password_not_required', 'high', o.name, `User ${o.name} is enabled and flagged "password not required".`, 'Clear the flag and set a strong password; check when and why it was set.', { subject: 'user' }));
|
|
53
|
+
if (o.enabled && o.never) { const svc = s.service_account_prefixes.some((p) => low(o.name).startsWith(low(p))); items.push(finding('password_never_expires', svc ? 'low' : 'medium', o.name, `${svc ? 'Service account' : 'User'} ${o.name} has a password that never expires.`, svc ? 'Move it to a managed service account or rotate its password on a schedule.' : 'Clear the flag; long passwords with MFA are fine to keep, but not ones that never change after a leak.', { subject: 'user' })); }
|
|
54
|
+
if (!o.enabled && o.memberOf.length) { const p = o.memberOf.filter((g) => priv.has(low(g))); items.push(finding('disabled_in_groups', p.length ? 'medium' : 'low', o.name, `Disabled account ${o.name} is still in ${o.memberOf.length} group(s)${p.length ? `, including ${p.join(', ')}` : ''}.`, 'Remove the memberships, so re-enabling the account by mistake does not restore its access.', { subject: 'user' })); }
|
|
55
|
+
}
|
|
56
|
+
if (o.type === 'group' && !builtin.has(low(o.name))) {
|
|
57
|
+
if (o.members === 0 && !o.nested.length) items.push(finding('empty_group', 'info', o.name, `Group ${o.name} has no members.`, 'Delete it if nothing grants access through it.', { subject: 'group' }));
|
|
58
|
+
if (!o.owner) items.push(finding('group_without_owner', 'low', o.name, `Group ${o.name} has no owner.`, 'Name the person or team who decides who belongs in it.', { subject: 'group' }));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const groups = new Map(objs.filter((o) => o.type === 'group').map((o) => [low(o.name), o]));
|
|
62
|
+
const seenLoop = new Set();
|
|
63
|
+
for (const g of groups.values()) {
|
|
64
|
+
const path = []; const onPath = new Set();
|
|
65
|
+
const visit = (n) => { const k = low(n); if (onPath.has(k)) { const raw = path.slice(path.indexOf(k)); const m = raw.indexOf([...raw].sort()[0]); const cyc = [...raw.slice(m), ...raw.slice(0, m)]; const key = [...cyc].sort().join(' > '); if (!seenLoop.has(key)) { seenLoop.add(key); items.push(finding('nested_group_loop', 'medium', key, `Groups ${cyc.map((x) => groups.get(x)?.name || x).join(' > ')} contain each other in a loop.`, 'Break the loop by removing one of the nested memberships.', { subject: 'group' })); } return; } const node = groups.get(k); if (!node || path.length > 50) return; path.push(k); onPath.add(k); for (const c of node.nested) visit(c); path.pop(); onPath.delete(k); };
|
|
66
|
+
visit(g.name);
|
|
67
|
+
}
|
|
68
|
+
const count = (t) => objs.filter((o) => o.type === t).length;
|
|
69
|
+
return { objects: objs.length, users: count('user'), computers: count('computer'), groups: count('group'), user_names: objs.filter((o) => o.type === 'user').map((o) => o.name), items };
|
|
70
|
+
}
|
package/src/manifest.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { wireAgent, fileArg, SETTINGS_ARG, AS_OF_ARG, settingsFrom, LIMITS, today } from 'fairwire-core';
|
|
3
|
+
import { OBJECT_FIELDS, SETTINGS_SCHEMA, DEFAULTS, reviewDirectory } from './logic.js';
|
|
4
|
+
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
6
|
+
const args = {
|
|
7
|
+
objects: fileArg('Directory export under --root (Active Directory PowerShell or ADManager export, Entra ID users, devices and groups as CSV, Excel or JSON): one row per user, computer or group with enabled, last logon, OS, password flags, member of, member count, managed by and nested groups'),
|
|
8
|
+
settings: SETTINGS_ARG('stale_days, unsupported_os, privileged_groups, service_account_prefixes, builtin_groups'),
|
|
9
|
+
as_of: AS_OF_ARG,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const manifest = wireAgent({
|
|
13
|
+
// Columns the "value is missing" checks depend on: an export without the column skips the check instead of flagging every row.
|
|
14
|
+
needs: { group_without_owner: ['managed_by'] },
|
|
15
|
+
pkg, prefix: 'directory', title: 'Fairwire Directory Hygiene',
|
|
16
|
+
description: 'Reviews Active Directory or Entra ID exports for hygiene: accounts with "password not required", nested group loops, passwords that never expire, unsupported computers, disabled accounts still in groups, stale computer objects, groups with no owner and empty groups. User names are masked for the model. Drafts clean-up lists; never edits the directory.',
|
|
17
|
+
args, required: ['objects'],
|
|
18
|
+
sources: { objects: { label: 'Directory objects', args: ['objects'], fields: OBJECT_FIELDS } },
|
|
19
|
+
configSchemas: { directory_settings: SETTINGS_SCHEMA },
|
|
20
|
+
run: (a, ctx) => { const o = reviewDirectory(ctx.records(a.objects, 'objects'), settingsFrom(a, ctx, 'directory_settings', DEFAULTS), a.as_of || today()); if (ctx.pii) for (const n of o.user_names) ctx.pii.register('user', n); const { user_names: _u, ...rest } = o; return rest; },
|
|
21
|
+
summary: (o) => `${o.objects} object(s): ${o.users} user(s), ${o.computers} computer(s), ${o.groups} group(s): ${o.open} open finding(s), ${o.high} high.`,
|
|
22
|
+
check: { title: 'Review directory hygiene', description: 'Review the directory export and list risky password flags, group loops, unsupported and stale computers, disabled members, ownerless and empty groups.' },
|
|
23
|
+
explain: { arg: 'name', argSchema: { type: 'string', maxLength: 200, description: 'User, computer or group from directory_check (a pseudonym is fine)' }, title: 'Explain one object', description: 'Every finding for one user, computer or group.', match: (i, v, ctx) => i.key === v || String(i.key).split(' > ').includes(String(v).toLowerCase()) || (ctx.pii && ctx.pii.same(i.key, v, 'user')) },
|
|
24
|
+
report: {
|
|
25
|
+
title: 'Directory hygiene', base: 'directory-hygiene',
|
|
26
|
+
sections: (o) => [{ title: 'By type', rows: ['user', 'computer', 'group'].map((type) => ({ type, findings: o.items.filter((i) => i.subject === type).length })), columns: ['type', 'findings'] }],
|
|
27
|
+
limits: [LIMITS.files, 'Last logon dates in Active Directory replicate slowly (lastLogonTimestamp can lag by up to two weeks); stale means "probably", so disable before deleting.', LIMITS.defaults, LIMITS.pii, LIMITS.live],
|
|
28
|
+
},
|
|
29
|
+
note: { noun: 'cleanup_list', verb: 'send', category: 'binding_send', actor: 'the directory owner', to: 'identity and directory administrators', subject: 'Directory clean-up to review', ask: 'Please fix the password flags first; disable stale objects before deleting anything.' },
|
|
30
|
+
refused: [
|
|
31
|
+
{ name: 'directory_modify_object', category: 'production_deploy', description: 'Fairwire Directory Hygiene never edits, disables, moves or deletes a directory object.' },
|
|
32
|
+
{ name: 'directory_remove_member', category: 'revoke_access', description: 'Fairwire Directory Hygiene never removes anyone from a group.' },
|
|
33
|
+
],
|
|
34
|
+
prompt: { title: 'Review directory hygiene', description: 'Walks the host model through a directory review with Fairwire Directory Hygiene.', text: 'You are helping a directory administrator review hygiene with fairwire-directory-hygiene. User names are pseudonyms. 1. Call directory_check; lead with "password not required" and group loops. 2. Use directory_explain for one object. 3. Call directory_write_report (the file has real names). 4. Offer directory_draft_cleanup_list; directory_request_send waits for one named click.' },
|
|
35
|
+
});
|