fairwire-vpn-access 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 ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ - First version (Fairwire ver 1).
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,215 @@
1
- # Temporary Holding Version
1
+ # Fairwire VPN Access
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ VPN and remote-access log review: sign-ins from countries outside your list, the same account in two far-apart places at once, failed-login bursts, sessions longer than your limit, accounts of leavers still connecting, shared accounts and old client versions. Names masked for the model. Drafts notes; never disables an account.
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
+ | `leaver_connected` | Someone on your leavers list connected after their last day. |
12
+ | `two_places_at_once` | One account connected from two countries within a time no one could travel. |
13
+ | `country_not_allowed` | A successful connection from a country outside your list. |
14
+ | `failed_login_burst` | Many failed sign-ins for one account in a few minutes (password guessing, or a stale saved password). |
15
+ | `shared_account` | One account had overlapping sessions from different addresses (a shared or stolen login). |
16
+ | `long_session` | A session longer than your limit. |
17
+ | `old_client` | A VPN client older than the version you require. |
18
+
19
+ 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.
20
+
21
+ ## Settings
22
+
23
+ Pass a settings file with `settings`. Every setting is optional; a misspelt setting is refused by name.
24
+
25
+ | Setting | What it does |
26
+ |---|---|
27
+ | `allowed_countries` | Countries people may connect from, as the export writes them (no check when empty) |
28
+ | `travel_hours` | Hours within which connections from two countries are flagged (default 2) |
29
+ | `burst_failures` | Failed sign-ins for one account that make a burst (default 10) |
30
+ | `burst_minutes` | Minutes the burst must fall within (default 15) |
31
+ | `max_session_hours` | Longest acceptable session in hours (default 24) |
32
+ | `min_client_version` | Oldest VPN client version you accept, e.g. "5.0" (no check when empty) |
33
+
34
+ ## What it never does
35
+
36
+ - `vpn_disconnect_session` is refused: Fairwire VPN Access never disconnects a session or disables an account; the identity owner does.
37
+ - `gateway_block_country` is refused: Fairwire VPN Access never changes the VPN gateway.
38
+ - `vpn_request_send` waits for one named person's click, even in Auto (`binding_send`).
39
+ - `vpn_accept_learning` waits for one named person's click, even in Auto (`accept_learning`).
40
+ - `vpn_retire_memory` waits for one named person's click, even in Auto (`accept_learning`).
41
+ - `vpn_disconnect_session` waits for one named person's click, even in Auto (`revoke_access`).
42
+ - `gateway_block_country` waits for one named person's click, even in Auto (`production_deploy`).
43
+
44
+ <!-- generated:start -->
45
+
46
+ ## A demo run
47
+
48
+ `npx -y fairwire-vpn-access demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
49
+
50
+ ```text
51
+ Fairwire VPN Access 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
+ 26 session(s) and sign-in(s) for 9 account(s), 12 failed, from 3 countr(ies): 7 open finding(s), 2 high.
56
+ high leaver_connected USR-24388969
57
+ high two_places_at_once USR-e7ac0cc2
58
+ medium country_not_allowed USR-e7ac0cc2
59
+ medium failed_login_burst USR-737f3b23
60
+ medium shared_account USR-119e2d32
61
+ low long_session USR-51719b06
62
+ low old_client USR-aeef5ebb
63
+
64
+ ▶ Explain one finding
65
+ status: executed decision: allow
66
+ high two_places_at_once: USR-e7ac0cc2 connected from US at 2026-11-16 09:00:00 and from RO at 2026-11-16 09:40:00. Fix: Ask the person; if it was not them, reset the password and revoke their sessions.
67
+ medium country_not_allowed: USR-e7ac0cc2 connected 1 time(s) from RO. Fix: Confirm the trip with the person or their manager; block the country at the gateway if no one travels there.
68
+
69
+ ▶ Write the worklist
70
+ status: executed decision: allow
71
+ Remote access review written: 26 session(s) and sign-in(s) for 9 account(s), 12 failed, from 3 countr(ies): 7 open finding(s), 2 high.
72
+
73
+ ▶ Draft the note for a person
74
+ status: executed decision: allow (auto)
75
+ access note 2026-11-18 drafted with 1 open marker(s) ([TO CONFIRM security and identity team]). Nothing was sent.
76
+
77
+ ▶ Auto: approving it still waits for one named person
78
+ status: needs_approval decision: ask
79
+ reason: binding_send stays one-click, even in Auto
80
+
81
+ ▶ The agent tries to change the live system itself
82
+ status: blocked decision: block
83
+ reason: Fairwire VPN Access never disconnects a session or disables an account; the identity owner does.
84
+ ```
85
+
86
+ ## Tools
87
+
88
+ | Tool | What it does | Policy |
89
+ |---|---|---|
90
+ | `vpn_check` | Review the VPN log by account and list leavers connecting, impossible travel, countries outside your list, failed bursts, shared accounts, long sessions and old clients. | runs |
91
+ | `vpn_explain` | Every finding for one account. | runs |
92
+ | `vpn_write_report` | Write vpn-access.csv (one row per finding, with blank owner and decision columns) and vpn-access.html into out_dir (default fairwire-out/vpn). | runs |
93
+ | `vpn_draft_access_note` | Write drafts/access_note-<date>.md: the open findings at or above min_severity (default medium), each with what to do, addressed to security and identity team. | asks first (Auto can be opted in) |
94
+ | `vpn_request_send` | After one named human click (even in Auto), record that the reviewed access note draft is approved in access_note-requests.csv. | one named click, even in Auto (`binding_send`) |
95
+ | `vpn_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
96
+ | `vpn_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
97
+ | `vpn_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
98
+ | `vpn_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
99
+ | `vpn_disconnect_session` | Fairwire VPN Access never disconnects a session or disables an account; the identity owner does. | refused |
100
+ | `gateway_block_country` | Fairwire VPN Access never changes the VPN gateway. | refused |
101
+
102
+ 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.
103
+
104
+ ## Columns it reads
105
+
106
+ 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.
107
+
108
+ ### VPN sessions (`sessions`)
109
+
110
+ | Column | Type | Also read as | For example, in other languages |
111
+ |---|---|---|---|
112
+ | `user` (required) | text | User, Username, User Name, Login, Account, UPN | Benutzer, Utilisateur, ユーザー, 用户 |
113
+ | `connected_at` (required) | date and time | Connected, Start, Start Time, Login Time, Session Start, Timestamp | - |
114
+ | `disconnected_at` | date and time | Disconnected, End, End Time, Logout Time, Session End | - |
115
+ | `client_ip` | text | Client IP, Public IP, Source IP, Remote IP, Real IP, Outside IP | IP-Adresse, Adresse IP, IPアドレス, IP地址 |
116
+ | `country` | text | Country, Geo, Location, Country Code, Source Country | Land, Pays, 国, 国家 |
117
+ | `result` | text | Result, Status, Outcome, Auth Result, Event | - |
118
+ | `client_version` | text | Client Version, Agent Version, Version, Client | - |
119
+ | `gateway` | text | Gateway, Portal, Concentrator, Server | - |
120
+
121
+ ### Leavers (`leavers`)
122
+
123
+ | Column | Type | Also read as | For example, in other languages |
124
+ |---|---|---|---|
125
+ | `user` (required) | text | User, Username, Login, Account, UPN, Email | Benutzer, Utilisateur, ユーザー, 用户 |
126
+ | `end_date` (required) | date | End Date, Last Day, Termination Date, Leaving Date, Exit Date | Austrittsdatum, Date de sortie, 退職日, 离职日期 |
127
+
128
+ ### Files from other countries
129
+
130
+ 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-vpn-access inspect <file>` (names and shapes only, never values) and name them in `fairwire-sources.json`:
131
+
132
+ ```json
133
+ { "files": { "exports/devices.csv": { "columns": { "host": "Gerätename" }, "date_order": "dmy" } } }
134
+ ```
135
+
136
+ ## Memory
137
+
138
+ fairwire-vpn-access can remember facts about your setup so the next run does not have to be told again. `vpn_learn` only proposes a fact; it changes nothing until a named person accepts it with `vpn_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`.
139
+
140
+ | Kind | What an accepted fact changes |
141
+ |---|---|
142
+ | `known_exception` | that finding is listed under "Accepted as known" instead of as open, until review_by (when given) has passed. |
143
+ | `note` | nothing (shown by recall only) |
144
+
145
+ ```bash
146
+ fairwire-vpn-access memory list
147
+ fairwire-vpn-access memory accept MEM-1a2b3c4d5e6f --as "Your Name"
148
+ fairwire-vpn-access memory retire MEM-1a2b3c4d5e6f --as "Your Name" --reason "rule removed"
149
+ ```
150
+
151
+ ## Install
152
+
153
+ Node 20 or newer. No other dependencies.
154
+
155
+ ```bash
156
+ npx -y fairwire-vpn-access demo
157
+ npx -y fairwire-vpn-access mcp --root /path/to/your/files
158
+ ```
159
+
160
+ Claude Desktop, Cursor and other MCP hosts:
161
+
162
+ ```json
163
+ {
164
+ "mcpServers": {
165
+ "fairwire-vpn-access": {
166
+ "command": "npx",
167
+ "args": [
168
+ "-y",
169
+ "fairwire-vpn-access",
170
+ "mcp",
171
+ "--root",
172
+ "/path/to/your/files"
173
+ ]
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
179
+ Claude Code: `claude mcp add fairwire-vpn-access -- npx -y fairwire-vpn-access mcp --root .`, or install the `fairwire-vpn-access` plugin from this repository's marketplace.
180
+
181
+ ## Modes and approvals
182
+
183
+ - **Review** (`--mode review`): reads and reports only.
184
+ - **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairwire-vpn-access approve <id> --as "Your Name"` (or on the local approvals page, `fairwire-vpn-access approvals`), and the same call is repeated.
185
+ - **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairwire-vpn-access 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.
186
+
187
+ ## CLI
188
+
189
+ ```bash
190
+ fairwire-vpn-access tools # every tool, its policy and arguments
191
+ fairwire-vpn-access sources # the columns each input is read from
192
+ fairwire-vpn-access inspect <file> # how a file would be read (names and shapes, never values)
193
+ fairwire-vpn-access call vpn_check '{"sessions":"<sessions>"}'
194
+ fairwire-vpn-access eval # the private eval cases on the fictional fixtures
195
+ fairwire-vpn-access demo
196
+ ```
197
+
198
+ ## Audit log and data
199
+
200
+ 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.
201
+
202
+ <!-- generated:end -->
203
+
204
+ ## Limits
205
+
206
+ - 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.
207
+ - Countries are the ones your gateway wrote; a VPN or mobile network can place a person in another country, so two countries is a question to ask, not proof.
208
+ - 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.
209
+ - 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.
210
+ - 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.
211
+ - 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.
212
+
213
+ ## Licence
214
+
215
+ 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-vpn-access', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,347 @@
1
+ {
2
+ "suite": "fairwire-vpn-access",
3
+ "root": "..",
4
+ "data_note": "Fictional VPN sessions in ../fixtures. No model is called.",
5
+ "cases": [
6
+ {
7
+ "id": "check-totals",
8
+ "tool": "vpn_check",
9
+ "args": {
10
+ "sessions": "fixtures/sessions.csv",
11
+ "leavers": "fixtures/leavers.csv",
12
+ "settings": "fixtures/settings.json"
13
+ },
14
+ "expect": {
15
+ "equals": {
16
+ "result.sessions": 26,
17
+ "result.users": 9,
18
+ "result.successful": 14,
19
+ "result.failed": 12,
20
+ "result.open": 7,
21
+ "result.high": 2
22
+ }
23
+ }
24
+ },
25
+ {
26
+ "id": "every-planted-issue",
27
+ "tool": "vpn_check",
28
+ "args": {
29
+ "sessions": "fixtures/sessions.csv",
30
+ "leavers": "fixtures/leavers.csv",
31
+ "settings": "fixtures/settings.json"
32
+ },
33
+ "expect": {
34
+ "contains": [
35
+ "leaver_connected",
36
+ "left on 2026-11-01",
37
+ "two_places_at_once",
38
+ "from RO",
39
+ "country_not_allowed",
40
+ "failed_login_burst",
41
+ "12 failed sign-ins",
42
+ "shared_account",
43
+ "long_session",
44
+ "49 hours",
45
+ "old_client",
46
+ "4.2.1"
47
+ ]
48
+ }
49
+ },
50
+ {
51
+ "id": "names-and-addresses-masked",
52
+ "tool": "vpn_check",
53
+ "args": {
54
+ "sessions": "fixtures/sessions.csv",
55
+ "leavers": "fixtures/leavers.csv",
56
+ "settings": "fixtures/settings.json"
57
+ },
58
+ "expect": {
59
+ "not_contains": [
60
+ "jdoe",
61
+ "aortiz",
62
+ "example.test",
63
+ "203.0.113.77"
64
+ ],
65
+ "matches": [
66
+ "USR-[0-9a-f]{8}"
67
+ ]
68
+ }
69
+ },
70
+ {
71
+ "id": "no-leavers-no-countries",
72
+ "tool": "vpn_check",
73
+ "args": {
74
+ "sessions": "fixtures/sessions.csv"
75
+ },
76
+ "expect": {
77
+ "equals": {
78
+ "result.open": 4,
79
+ "result.high": 1
80
+ },
81
+ "not_contains": [
82
+ "leaver_connected",
83
+ "country_not_allowed",
84
+ "old_client"
85
+ ]
86
+ }
87
+ },
88
+ {
89
+ "id": "explain-traveller",
90
+ "tool": "vpn_explain",
91
+ "args": {
92
+ "sessions": "fixtures/sessions.csv",
93
+ "leavers": "fixtures/leavers.csv",
94
+ "settings": "fixtures/settings.json",
95
+ "user": "aortiz@example.test"
96
+ },
97
+ "expect": {
98
+ "contains": [
99
+ "two_places_at_once",
100
+ "country_not_allowed"
101
+ ],
102
+ "equals": {
103
+ "result.findings": 2
104
+ }
105
+ }
106
+ },
107
+ {
108
+ "id": "draft-after-approval",
109
+ "tool": "vpn_draft_access_note",
110
+ "approve": "Pat Example",
111
+ "args": {
112
+ "sessions": "fixtures/sessions.csv",
113
+ "leavers": "fixtures/leavers.csv",
114
+ "settings": "fixtures/settings.json"
115
+ },
116
+ "expect": {
117
+ "status": "executed",
118
+ "contains": [
119
+ "Nothing was sent"
120
+ ],
121
+ "equals": {
122
+ "result.items": 5,
123
+ "result.open_markers": 1
124
+ }
125
+ }
126
+ },
127
+ {
128
+ "id": "review-mode-still-reads",
129
+ "tool": "vpn_check",
130
+ "mode": "review",
131
+ "args": {
132
+ "sessions": "fixtures/sessions.csv",
133
+ "leavers": "fixtures/leavers.csv",
134
+ "settings": "fixtures/settings.json"
135
+ },
136
+ "expect": {
137
+ "status": "executed",
138
+ "equals": {
139
+ "result.sessions": 26,
140
+ "result.users": 9,
141
+ "result.successful": 14,
142
+ "result.failed": 12,
143
+ "result.open": 7,
144
+ "result.high": 2
145
+ }
146
+ },
147
+ "generated": true
148
+ },
149
+ {
150
+ "id": "severity-filter",
151
+ "tool": "vpn_check",
152
+ "args": {
153
+ "sessions": "fixtures/sessions.csv",
154
+ "leavers": "fixtures/leavers.csv",
155
+ "settings": "fixtures/settings.json",
156
+ "severity": "high"
157
+ },
158
+ "expect": {
159
+ "status": "executed",
160
+ "equals": {
161
+ "result.findings": 2
162
+ }
163
+ },
164
+ "generated": true
165
+ },
166
+ {
167
+ "id": "missing-argument-named",
168
+ "tool": "vpn_check",
169
+ "args": {},
170
+ "expect": {
171
+ "status": "error",
172
+ "contains": [
173
+ "sessions"
174
+ ]
175
+ },
176
+ "generated": true
177
+ },
178
+ {
179
+ "id": "file-outside-root-refused",
180
+ "tool": "vpn_check",
181
+ "args": {
182
+ "sessions": "../../../outside.csv",
183
+ "leavers": "fixtures/leavers.csv",
184
+ "settings": "fixtures/settings.json"
185
+ },
186
+ "expect": {
187
+ "status": "error",
188
+ "contains": [
189
+ "outside"
190
+ ]
191
+ },
192
+ "generated": true
193
+ },
194
+ {
195
+ "id": "invented-tool-name-refused",
196
+ "tool": "vpn_apply_every_fix_now",
197
+ "args": {},
198
+ "expect": {
199
+ "status": "blocked"
200
+ },
201
+ "generated": true
202
+ },
203
+ {
204
+ "id": "write-report-writes-files",
205
+ "tool": "vpn_write_report",
206
+ "args": {
207
+ "sessions": "fixtures/sessions.csv",
208
+ "leavers": "fixtures/leavers.csv",
209
+ "settings": "fixtures/settings.json"
210
+ },
211
+ "expect": {
212
+ "status": "executed",
213
+ "contains": [
214
+ "vpn-access.csv",
215
+ "vpn-access.html"
216
+ ]
217
+ },
218
+ "generated": true
219
+ },
220
+ {
221
+ "id": "recall-memory-starts-empty",
222
+ "tool": "vpn_recall",
223
+ "args": {},
224
+ "expect": {
225
+ "status": "executed",
226
+ "contains": [
227
+ "memory is empty"
228
+ ]
229
+ },
230
+ "generated": true
231
+ },
232
+ {
233
+ "id": "accept-learning-stays-one-click",
234
+ "tool": "vpn_accept_learning",
235
+ "mode": "auto",
236
+ "args": {
237
+ "id": "MEM-000000000000",
238
+ "decision": "accept"
239
+ },
240
+ "expect": {
241
+ "status": "needs_approval"
242
+ },
243
+ "generated": true
244
+ },
245
+ {
246
+ "id": "never-vpn-disconnect-session",
247
+ "tool": "vpn_disconnect_session",
248
+ "mode": "auto",
249
+ "args": {},
250
+ "expect": {
251
+ "status": "blocked"
252
+ },
253
+ "generated": true
254
+ },
255
+ {
256
+ "id": "never-gateway-block-country",
257
+ "tool": "gateway_block_country",
258
+ "mode": "auto",
259
+ "args": {},
260
+ "expect": {
261
+ "status": "blocked"
262
+ },
263
+ "generated": true
264
+ },
265
+ {
266
+ "id": "draft-waits-for-a-person",
267
+ "tool": "vpn_draft_access_note",
268
+ "args": {
269
+ "sessions": "fixtures/sessions.csv",
270
+ "leavers": "fixtures/leavers.csv",
271
+ "settings": "fixtures/settings.json"
272
+ },
273
+ "expect": {
274
+ "status": "needs_approval",
275
+ "decision": "ask"
276
+ },
277
+ "generated": true
278
+ },
279
+ {
280
+ "id": "review-mode-drafts-nothing",
281
+ "tool": "vpn_draft_access_note",
282
+ "mode": "review",
283
+ "args": {
284
+ "sessions": "fixtures/sessions.csv",
285
+ "leavers": "fixtures/leavers.csv",
286
+ "settings": "fixtures/settings.json"
287
+ },
288
+ "expect": {
289
+ "status": "blocked"
290
+ },
291
+ "generated": true
292
+ },
293
+ {
294
+ "id": "request-stays-one-click",
295
+ "tool": "vpn_request_send",
296
+ "mode": "auto",
297
+ "args": {
298
+ "draft": "fixtures/README.md",
299
+ "draft_sha256": "0000000000000000000000000000000000000000000000000000000000000000"
300
+ },
301
+ "expect": {
302
+ "status": "needs_approval"
303
+ },
304
+ "generated": true
305
+ },
306
+ {
307
+ "id": "intl-de-check-totals",
308
+ "tool": "vpn_check",
309
+ "args": {
310
+ "sessions": "fixtures/intl/de/sessions.csv",
311
+ "leavers": "fixtures/intl/de/leavers.csv",
312
+ "settings": "fixtures/settings.json"
313
+ },
314
+ "expect": {
315
+ "equals": {
316
+ "result.sessions": 26,
317
+ "result.users": 9,
318
+ "result.successful": 14,
319
+ "result.failed": 12,
320
+ "result.open": 7,
321
+ "result.high": 2
322
+ }
323
+ },
324
+ "note": "German export of the same data (fixtures/intl/de); must match the English case \"check-totals\"."
325
+ },
326
+ {
327
+ "id": "intl-ja-check-totals",
328
+ "tool": "vpn_check",
329
+ "args": {
330
+ "sessions": "fixtures/intl/ja/sessions.csv",
331
+ "leavers": "fixtures/intl/ja/leavers.csv",
332
+ "settings": "fixtures/settings.json"
333
+ },
334
+ "expect": {
335
+ "equals": {
336
+ "result.sessions": 26,
337
+ "result.users": 9,
338
+ "result.successful": 14,
339
+ "result.failed": 12,
340
+ "result.open": 7,
341
+ "result.high": 2
342
+ }
343
+ },
344
+ "note": "Japanese export of the same data (fixtures/intl/ja); must match the English case \"check-totals\"."
345
+ }
346
+ ]
347
+ }
@@ -0,0 +1,7 @@
1
+ # Fairwire VPN Access fixtures
2
+
3
+ Fictional VPN sessions for made-up accounts at example.test, from documentation address ranges.
4
+
5
+ - `sessions.csv`: 26 rows. jdoe connects after leaving on 1 November. aortiz connects from the US and from Romania 40 minutes apart. bkim has 12 failed sign-ins at 3 am. cdiaz stays connected 49 hours. svc-shared has two sessions at once from two addresses. dlee uses client 4.2.1. Three people connect normally.
6
+ - `leavers.csv`: two people who left.
7
+ - `settings.json`: US and Canada allowed; client 5.0 or newer.
@@ -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,3 @@
1
+ Benutzer;Austrittsdatum
2
+ jdoe@example.test;01.11.2026
3
+ old.hand@example.test;15.10.2026
@@ -0,0 +1,27 @@
1
+ Benutzer;connected_at;disconnected_at;IP-Adresse;Land;result;client_version;gateway
2
+ jdoe@example.test;10.11.2026 08:00:00;10.11.2026 12:00:00;198.51.100.40;US;success;5.2.1;gw-east
3
+ aortiz@example.test;16.11.2026 09:00:00;16.11.2026 10:00:00;198.51.100.11;US;success;5.2.1;gw-east
4
+ aortiz@example.test;16.11.2026 09:40:00;16.11.2026 09:55:00;203.0.113.77;RO;success;5.2.1;gw-east
5
+ bkim@example.test;16.11.2026 03:00:00;;203.0.113.150;US;failure;5.2.1;gw-east
6
+ bkim@example.test;16.11.2026 03:00:07;;203.0.113.150;US;failure;5.2.1;gw-east
7
+ bkim@example.test;16.11.2026 03:01:14;;203.0.113.150;US;failure;5.2.1;gw-east
8
+ bkim@example.test;16.11.2026 03:02:21;;203.0.113.150;US;failure;5.2.1;gw-east
9
+ bkim@example.test;16.11.2026 03:03:28;;203.0.113.150;US;failure;5.2.1;gw-east
10
+ bkim@example.test;16.11.2026 03:04:35;;203.0.113.150;US;failure;5.2.1;gw-east
11
+ bkim@example.test;16.11.2026 03:04:42;;203.0.113.150;US;failure;5.2.1;gw-east
12
+ bkim@example.test;16.11.2026 03:05:49;;203.0.113.150;US;failure;5.2.1;gw-east
13
+ bkim@example.test;16.11.2026 03:06:56;;203.0.113.150;US;failure;5.2.1;gw-east
14
+ bkim@example.test;16.11.2026 03:07:03;;203.0.113.150;US;failure;5.2.1;gw-east
15
+ bkim@example.test;16.11.2026 03:08:10;;203.0.113.150;US;failure;5.2.1;gw-east
16
+ bkim@example.test;16.11.2026 03:08:17;;203.0.113.150;US;failure;5.2.1;gw-east
17
+ bkim@example.test;16.11.2026 09:00:00;16.11.2026 17:00:00;198.51.100.12;US;success;5.2.1;gw-east
18
+ cdiaz@example.test;14.11.2026 08:00:00;16.11.2026 09:00:00;198.51.100.13;US;success;5.2.1;gw-east
19
+ svc-shared@example.test;16.11.2026 08:00:00;16.11.2026 12:00:00;198.51.100.20;US;success;5.2.1;gw-east
20
+ svc-shared@example.test;16.11.2026 09:00:00;16.11.2026 11:00:00;198.51.100.99;US;success;5.2.1;gw-east
21
+ dlee@example.test;16.11.2026 10:00:00;16.11.2026 11:00:00;198.51.100.14;CA;success;4.2.1;gw-east
22
+ emma@example.test;16.11.2026 08:30:00;16.11.2026 16:30:00;198.51.100.15;US;success;5.2.1;gw-east
23
+ emma@example.test;17.11.2026 08:30:00;17.11.2026 16:30:00;198.51.100.15;US;success;5.2.1;gw-east
24
+ fred@example.test;16.11.2026 08:30:00;16.11.2026 16:30:00;198.51.100.16;US;success;5.2.1;gw-east
25
+ fred@example.test;17.11.2026 08:30:00;17.11.2026 16:30:00;198.51.100.16;US;success;5.2.1;gw-east
26
+ gina@example.test;16.11.2026 08:30:00;16.11.2026 16:30:00;198.51.100.17;US;success;5.2.1;gw-east
27
+ gina@example.test;17.11.2026 08:30:00;17.11.2026 16:30:00;198.51.100.17;US;success;5.2.1;gw-east
@@ -0,0 +1,3 @@
1
+ ���[�U�[,�ސE��
2
+ jdoe@example.test,2026/11/01
3
+ old.hand@example.test,2026/10/15
@@ -0,0 +1,27 @@
1
+ ���[�U�[,connected_at,disconnected_at,IP�A�h���X,��,result,client_version,gateway
2
+ jdoe@example.test,2026/11/10 08:00:00,2026/11/10 12:00:00,198.51.100.40,US,success,5.2.1,gw-east
3
+ aortiz@example.test,2026/11/16 09:00:00,2026/11/16 10:00:00,198.51.100.11,US,success,5.2.1,gw-east
4
+ aortiz@example.test,2026/11/16 09:40:00,2026/11/16 09:55:00,203.0.113.77,RO,success,5.2.1,gw-east
5
+ bkim@example.test,2026/11/16 03:00:00,,203.0.113.150,US,failure,5.2.1,gw-east
6
+ bkim@example.test,2026/11/16 03:00:07,,203.0.113.150,US,failure,5.2.1,gw-east
7
+ bkim@example.test,2026/11/16 03:01:14,,203.0.113.150,US,failure,5.2.1,gw-east
8
+ bkim@example.test,2026/11/16 03:02:21,,203.0.113.150,US,failure,5.2.1,gw-east
9
+ bkim@example.test,2026/11/16 03:03:28,,203.0.113.150,US,failure,5.2.1,gw-east
10
+ bkim@example.test,2026/11/16 03:04:35,,203.0.113.150,US,failure,5.2.1,gw-east
11
+ bkim@example.test,2026/11/16 03:04:42,,203.0.113.150,US,failure,5.2.1,gw-east
12
+ bkim@example.test,2026/11/16 03:05:49,,203.0.113.150,US,failure,5.2.1,gw-east
13
+ bkim@example.test,2026/11/16 03:06:56,,203.0.113.150,US,failure,5.2.1,gw-east
14
+ bkim@example.test,2026/11/16 03:07:03,,203.0.113.150,US,failure,5.2.1,gw-east
15
+ bkim@example.test,2026/11/16 03:08:10,,203.0.113.150,US,failure,5.2.1,gw-east
16
+ bkim@example.test,2026/11/16 03:08:17,,203.0.113.150,US,failure,5.2.1,gw-east
17
+ bkim@example.test,2026/11/16 09:00:00,2026/11/16 17:00:00,198.51.100.12,US,success,5.2.1,gw-east
18
+ cdiaz@example.test,2026/11/14 08:00:00,2026/11/16 09:00:00,198.51.100.13,US,success,5.2.1,gw-east
19
+ svc-shared@example.test,2026/11/16 08:00:00,2026/11/16 12:00:00,198.51.100.20,US,success,5.2.1,gw-east
20
+ svc-shared@example.test,2026/11/16 09:00:00,2026/11/16 11:00:00,198.51.100.99,US,success,5.2.1,gw-east
21
+ dlee@example.test,2026/11/16 10:00:00,2026/11/16 11:00:00,198.51.100.14,CA,success,4.2.1,gw-east
22
+ emma@example.test,2026/11/16 08:30:00,2026/11/16 16:30:00,198.51.100.15,US,success,5.2.1,gw-east
23
+ emma@example.test,2026/11/17 08:30:00,2026/11/17 16:30:00,198.51.100.15,US,success,5.2.1,gw-east
24
+ fred@example.test,2026/11/16 08:30:00,2026/11/16 16:30:00,198.51.100.16,US,success,5.2.1,gw-east
25
+ fred@example.test,2026/11/17 08:30:00,2026/11/17 16:30:00,198.51.100.16,US,success,5.2.1,gw-east
26
+ gina@example.test,2026/11/16 08:30:00,2026/11/16 16:30:00,198.51.100.17,US,success,5.2.1,gw-east
27
+ gina@example.test,2026/11/17 08:30:00,2026/11/17 16:30:00,198.51.100.17,US,success,5.2.1,gw-east
@@ -0,0 +1,3 @@
1
+ user,end_date
2
+ jdoe@example.test,2026-11-01
3
+ old.hand@example.test,2026-10-15
@@ -0,0 +1,27 @@
1
+ user,connected_at,disconnected_at,client_ip,country,result,client_version,gateway
2
+ jdoe@example.test,2026-11-10 08:00:00,2026-11-10 12:00:00,198.51.100.40,US,success,5.2.1,gw-east
3
+ aortiz@example.test,2026-11-16 09:00:00,2026-11-16 10:00:00,198.51.100.11,US,success,5.2.1,gw-east
4
+ aortiz@example.test,2026-11-16 09:40:00,2026-11-16 09:55:00,203.0.113.77,RO,success,5.2.1,gw-east
5
+ bkim@example.test,2026-11-16 03:00:00,,203.0.113.150,US,failure,5.2.1,gw-east
6
+ bkim@example.test,2026-11-16 03:00:07,,203.0.113.150,US,failure,5.2.1,gw-east
7
+ bkim@example.test,2026-11-16 03:01:14,,203.0.113.150,US,failure,5.2.1,gw-east
8
+ bkim@example.test,2026-11-16 03:02:21,,203.0.113.150,US,failure,5.2.1,gw-east
9
+ bkim@example.test,2026-11-16 03:03:28,,203.0.113.150,US,failure,5.2.1,gw-east
10
+ bkim@example.test,2026-11-16 03:04:35,,203.0.113.150,US,failure,5.2.1,gw-east
11
+ bkim@example.test,2026-11-16 03:04:42,,203.0.113.150,US,failure,5.2.1,gw-east
12
+ bkim@example.test,2026-11-16 03:05:49,,203.0.113.150,US,failure,5.2.1,gw-east
13
+ bkim@example.test,2026-11-16 03:06:56,,203.0.113.150,US,failure,5.2.1,gw-east
14
+ bkim@example.test,2026-11-16 03:07:03,,203.0.113.150,US,failure,5.2.1,gw-east
15
+ bkim@example.test,2026-11-16 03:08:10,,203.0.113.150,US,failure,5.2.1,gw-east
16
+ bkim@example.test,2026-11-16 03:08:17,,203.0.113.150,US,failure,5.2.1,gw-east
17
+ bkim@example.test,2026-11-16 09:00:00,2026-11-16 17:00:00,198.51.100.12,US,success,5.2.1,gw-east
18
+ cdiaz@example.test,2026-11-14 08:00:00,2026-11-16 09:00:00,198.51.100.13,US,success,5.2.1,gw-east
19
+ svc-shared@example.test,2026-11-16 08:00:00,2026-11-16 12:00:00,198.51.100.20,US,success,5.2.1,gw-east
20
+ svc-shared@example.test,2026-11-16 09:00:00,2026-11-16 11:00:00,198.51.100.99,US,success,5.2.1,gw-east
21
+ dlee@example.test,2026-11-16 10:00:00,2026-11-16 11:00:00,198.51.100.14,CA,success,4.2.1,gw-east
22
+ emma@example.test,2026-11-16 08:30:00,2026-11-16 16:30:00,198.51.100.15,US,success,5.2.1,gw-east
23
+ emma@example.test,2026-11-17 08:30:00,2026-11-17 16:30:00,198.51.100.15,US,success,5.2.1,gw-east
24
+ fred@example.test,2026-11-16 08:30:00,2026-11-16 16:30:00,198.51.100.16,US,success,5.2.1,gw-east
25
+ fred@example.test,2026-11-17 08:30:00,2026-11-17 16:30:00,198.51.100.16,US,success,5.2.1,gw-east
26
+ gina@example.test,2026-11-16 08:30:00,2026-11-16 16:30:00,198.51.100.17,US,success,5.2.1,gw-east
27
+ gina@example.test,2026-11-17 08:30:00,2026-11-17 16:30:00,198.51.100.17,US,success,5.2.1,gw-east
@@ -0,0 +1,4 @@
1
+ {
2
+ "allowed_countries": ["US", "CA"],
3
+ "min_client_version": "5.0"
4
+ }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "fairwire-vpn-access",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.fpavia111-creator/fairwire-vpn-access",
5
+ "description": "Fairwire VPN Access: VPN and remote-access log review: sign-ins from countries outside your list, the same account in two far-apart places at once, failed-login bursts, sessions longer than your limit, accounts of leavers still connecting, shared accounts and old client versions. Names masked for the model. Drafts notes; never disables an account.",
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-vpn-access": "bin/fairwire-vpn-access.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-vpn-access.js demo",
33
+ "eval": "node bin/fairwire-vpn-access.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-vpn-access"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairwire-agents/tree/master/packages/fairwire-vpn-access#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
+ "vpn",
54
+ "remote-access",
55
+ "impossible-travel",
56
+ "brute-force",
57
+ "zero-trust"
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-vpn-access",
4
+ "title": "Fairwire VPN Access",
5
+ "description": "Fairwire VPN Access: VPN and remote-access log review: sign-ins from countries outside your list…",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairwire-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairwire-vpn-access"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairwire.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairwire-vpn-access",
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 VPN Access 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
@@ -0,0 +1,2 @@
1
+ export { manifest } from './manifest.js';
2
+ export * from './logic.js';
package/src/logic.js ADDED
@@ -0,0 +1,68 @@
1
+ // Fairwire VPN Access: remote-access log review. Pure functions.
2
+ import { str, low, toMs, isoDate, hoursBetween, versionCompare, cleanIp, round1, finding } from 'fairwire-core';
3
+
4
+ export const CHECKS = Object.freeze({
5
+ leaver_connected: 'Someone on your leavers list connected after their last day.',
6
+ two_places_at_once: 'One account connected from two countries within a time no one could travel.',
7
+ country_not_allowed: 'A successful connection from a country outside your list.',
8
+ failed_login_burst: 'Many failed sign-ins for one account in a few minutes (password guessing, or a stale saved password).',
9
+ shared_account: 'One account had overlapping sessions from different addresses (a shared or stolen login).',
10
+ long_session: 'A session longer than your limit.',
11
+ old_client: 'A VPN client older than the version you require.',
12
+ });
13
+
14
+ export const SESSION_FIELDS = Object.freeze({
15
+ user: { aliases: ['User', 'Username', 'User Name', 'Login', 'Account', 'UPN'], required: true, pii: 'user' },
16
+ connected_at: { type: 'datetime', aliases: ['Connected', 'Start', 'Start Time', 'Login Time', 'Session Start', 'Timestamp'], required: true },
17
+ disconnected_at: { type: 'datetime', aliases: ['Disconnected', 'End', 'End Time', 'Logout Time', 'Session End'] },
18
+ client_ip: { aliases: ['Client IP', 'Public IP', 'Source IP', 'Remote IP', 'Real IP', 'Outside IP'], pii: 'ip' },
19
+ country: { aliases: ['Country', 'Geo', 'Location', 'Country Code', 'Source Country'] },
20
+ result: { aliases: ['Result', 'Status', 'Outcome', 'Auth Result', 'Event'] },
21
+ client_version: { aliases: ['Client Version', 'Agent Version', 'Version', 'Client'] },
22
+ gateway: { aliases: ['Gateway', 'Portal', 'Concentrator', 'Server'] },
23
+ });
24
+ export const LEAVER_FIELDS = Object.freeze({
25
+ user: { aliases: ['User', 'Username', 'Login', 'Account', 'UPN', 'Email'], required: true, pii: 'user' },
26
+ end_date: { type: 'date', aliases: ['End Date', 'Last Day', 'Termination Date', 'Leaving Date', 'Exit Date'], required: true },
27
+ });
28
+
29
+ export const SETTINGS_SCHEMA = { type: 'object', additionalProperties: false, properties: {
30
+ allowed_countries: { type: 'array', items: { type: 'string' }, maxItems: 250, description: 'Countries people may connect from, as the export writes them (no check when empty)' },
31
+ travel_hours: { type: 'number', minimum: 0, description: 'Hours within which connections from two countries are flagged (default 2)' },
32
+ burst_failures: { type: 'integer', minimum: 2, description: 'Failed sign-ins for one account that make a burst (default 10)' },
33
+ burst_minutes: { type: 'number', minimum: 1, description: 'Minutes the burst must fall within (default 15)' },
34
+ max_session_hours: { type: 'number', minimum: 1, description: 'Longest acceptable session in hours (default 24)' },
35
+ min_client_version: { type: 'string', maxLength: 40, description: 'Oldest VPN client version you accept, e.g. "5.0" (no check when empty)' },
36
+ } };
37
+ export const DEFAULTS = Object.freeze({ allowed_countries: [], travel_hours: 2, burst_failures: 10, burst_minutes: 15, max_session_hours: 24, min_client_version: '' });
38
+
39
+ const OK = /^(success|succeeded|ok|connected|login|logged in|allowed|pass|passed|accept|accepted|true|yes|1)$/i;
40
+
41
+ export function reviewSessions(rows, leaverRows = [], settings = {}) {
42
+ const s = { ...DEFAULTS, ...settings };
43
+ const ss = rows.filter((r) => str(r.user) && str(r.connected_at)).map((r) => ({ user: low(r.user), shown: str(r.user), start: str(r.connected_at), end: str(r.disconnected_at), ip: cleanIp(r.client_ip), country: str(r.country), ok: !str(r.result) || OK.test(str(r.result)), version: str(r.client_version) }));
44
+ const leavers = new Map(leaverRows.filter((r) => str(r.user) && isoDate(r.end_date)).map((r) => [low(r.user), isoDate(r.end_date)]));
45
+ const allowed = s.allowed_countries.map(low);
46
+ const items = []; const byUser = new Map();
47
+ for (const x of ss) byUser.set(x.user, [...(byUser.get(x.user) || []), x]);
48
+ for (const [, list] of byUser) {
49
+ list.sort((a, b) => toMs(a.start) - toMs(b.start) || (a.ip < b.ip ? -1 : 1));
50
+ const u = list[0].shown; const ok = list.filter((x) => x.ok);
51
+ const end = leavers.get(list[0].user);
52
+ if (end) { const after = ok.filter((x) => isoDate(x.start) > end); if (after.length) items.push(finding('leaver_connected', 'high', u, `${u} left on ${end} but connected ${after.length} time(s) after that (last ${after.at(-1).start}).`, 'Disable the account and its VPN access today and find out who used it.', { subject: u })); }
53
+ let travel = null;
54
+ for (let i = 1; i < ok.length && !travel; i++) for (let j = 0; j < i; j++) { const a = ok[j], b = ok[i]; if (a.country && b.country && low(a.country) !== low(b.country) && Math.abs(hoursBetween(a.start, b.start)) <= s.travel_hours) { travel = [a, b]; break; } }
55
+ if (travel) items.push(finding('two_places_at_once', 'high', u, `${u} connected from ${travel[0].country} at ${travel[0].start} and from ${travel[1].country} at ${travel[1].start}.`, 'Ask the person; if it was not them, reset the password and revoke their sessions.', { subject: u }));
56
+ if (allowed.length) { const bad = ok.filter((x) => x.country && !allowed.includes(low(x.country))); if (bad.length) items.push(finding('country_not_allowed', 'medium', u, `${u} connected ${bad.length} time(s) from ${[...new Set(bad.map((x) => x.country))].sort().join(', ')}.`, 'Confirm the trip with the person or their manager; block the country at the gateway if no one travels there.', { subject: u })); }
57
+ const fails = list.filter((x) => !x.ok).map((x) => toMs(x.start)).filter(Number.isFinite).sort((a, b) => a - b);
58
+ let burst = 0; for (let i = 0, j = 0; j < fails.length; j++) { while (fails[j] - fails[i] > s.burst_minutes * 60000) i++; burst = Math.max(burst, j - i + 1); }
59
+ if (burst >= s.burst_failures) items.push(finding('failed_login_burst', 'medium', u, `${u} had ${burst} failed sign-ins within ${s.burst_minutes} minutes.`, 'Check whether the account is locked and whether a device keeps an old password; watch the source addresses.', { subject: u, failures: burst }));
60
+ let shared = null;
61
+ for (let i = 1; i < ok.length && !shared; i++) for (let j = 0; j < i; j++) { const a = ok[j], b = ok[i]; const aEnd = toMs(a.end); if (a.ip && b.ip && a.ip !== b.ip && Number.isFinite(aEnd) && toMs(b.start) < aEnd && (!a.country || !b.country || low(a.country) === low(b.country))) { shared = [a, b]; break; } }
62
+ if (shared) items.push(finding('shared_account', 'medium', u, `${u} had two sessions at once from different addresses (${shared[0].start} and ${shared[1].start}).`, 'Give each person their own account; if the account is not shared, treat it as stolen.', { subject: u }));
63
+ const longest = ok.map((x) => hoursBetween(x.start, x.end)).filter((h) => h !== null).sort((a, b) => b - a)[0];
64
+ if (longest !== undefined && longest > s.max_session_hours) items.push(finding('long_session', 'low', u, `${u} stayed connected for ${round1(longest)} hours.`, 'Set a session time-out on the gateway and ask whether the connection was left open by a forgotten device.', { subject: u, hours: round1(longest) }));
65
+ if (s.min_client_version) { const old = ok.filter((x) => x.version && versionCompare(x.version, s.min_client_version) < 0); if (old.length) items.push(finding('old_client', 'low', u, `${u} connected with client ${[...new Set(old.map((x) => x.version))].sort().join(', ')}, older than ${s.min_client_version}.`, 'Update the VPN client on this person\'s device.', { subject: u })); }
66
+ }
67
+ return { sessions: ss.length, users: byUser.size, successful: ss.filter((x) => x.ok).length, failed: ss.filter((x) => !x.ok).length, countries: [...new Set(ss.map((x) => x.country).filter(Boolean))].sort(), items };
68
+ }
@@ -0,0 +1,33 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { wireAgent, fileArg, SETTINGS_ARG, settingsFrom, LIMITS } from 'fairwire-core';
3
+ import { SESSION_FIELDS, LEAVER_FIELDS, SETTINGS_SCHEMA, DEFAULTS, reviewSessions } from './logic.js';
4
+
5
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
6
+ const args = {
7
+ sessions: fileArg('VPN or remote-access log under --root (GlobalProtect, AnyConnect, FortiClient, WireGuard gateway or any CSV, Excel or JSON): one row per session or sign-in attempt with user, start, end, client address, country, result and client version'),
8
+ leavers: fileArg('Optional list of people who left, with their last day (HR export)'),
9
+ settings: SETTINGS_ARG('allowed_countries, travel_hours, burst_failures, burst_minutes, max_session_hours, min_client_version'),
10
+ };
11
+
12
+ export const manifest = wireAgent({
13
+ pkg, prefix: 'vpn', title: 'Fairwire VPN Access',
14
+ description: 'Reviews VPN and remote-access logs: leavers still connecting, one account in two countries at once, countries outside your list, failed sign-in bursts, shared accounts, sessions longer than your limit and old client versions. User names and client addresses are masked for the model. Drafts notes; never disables an account.',
15
+ args, required: ['sessions'],
16
+ sources: { sessions: { label: 'VPN sessions', args: ['sessions'], fields: SESSION_FIELDS }, leavers: { label: 'Leavers', args: ['leavers'], fields: LEAVER_FIELDS } },
17
+ configSchemas: { vpn_settings: SETTINGS_SCHEMA },
18
+ run: (a, ctx) => reviewSessions(ctx.records(a.sessions, 'sessions'), a.leavers ? ctx.records(a.leavers, 'leavers') : [], settingsFrom(a, ctx, 'vpn_settings', DEFAULTS)),
19
+ summary: (o) => `${o.sessions} session(s) and sign-in(s) for ${o.users} account(s), ${o.failed} failed, from ${o.countries.length} countr(ies): ${o.open} open finding(s), ${o.high} high.`,
20
+ check: { title: 'Review remote access', description: 'Review the VPN log by account and list leavers connecting, impossible travel, countries outside your list, failed bursts, shared accounts, long sessions and old clients.' },
21
+ explain: { arg: 'user', argSchema: { type: 'string', maxLength: 200, description: 'Account from vpn_check (the pseudonym is fine)' }, title: 'Explain one account', description: 'Every finding for one account.', match: (i, v, ctx) => i.key === v || (ctx.pii && ctx.pii.same(i.key, v, 'user')) },
22
+ report: {
23
+ title: 'Remote access review', base: 'vpn-access',
24
+ sections: (o) => [{ title: 'By user', rows: [...new Set(o.items.map((i) => i.key))].map((user) => ({ user, findings: o.items.filter((i) => i.key === user).map((i) => i.code).join(' ') })), columns: ['user', 'findings'] }],
25
+ limits: [LIMITS.files, 'Countries are the ones your gateway wrote; a VPN or mobile network can place a person in another country, so two countries is a question to ask, not proof.', LIMITS.defaults, LIMITS.pii, LIMITS.live],
26
+ },
27
+ note: { noun: 'access_note', verb: 'send', category: 'binding_send', actor: 'the identity owner', to: 'security and identity team', subject: 'Remote access to check', ask: 'Please confirm each item with the person or their manager before any account is disabled.' },
28
+ refused: [
29
+ { name: 'vpn_disconnect_session', category: 'revoke_access', description: 'Fairwire VPN Access never disconnects a session or disables an account; the identity owner does.' },
30
+ { name: 'gateway_block_country', category: 'production_deploy', description: 'Fairwire VPN Access never changes the VPN gateway.' },
31
+ ],
32
+ prompt: { title: 'Review remote access', description: 'Walks the host model through a VPN log review with Fairwire VPN Access.', text: 'You are helping a security lead review VPN logs with fairwire-vpn-access. Names are pseudonyms; Fairwire VPN Access never disconnects anyone. 1. Call vpn_check; lead with leavers connecting and two places at once. 2. Use vpn_explain with the pseudonym. 3. Call vpn_write_report (the file has real names, for the team). 4. Offer vpn_draft_access_note; vpn_request_send waits for one named click.' },
33
+ });