proofbench-collector 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ # ============================================================
2
+ # ProofBench · .gitignore
3
+ # ============================================================
4
+
5
+ # ── Secrets (never commit) ──────────────────────────────────
6
+ .env
7
+ .env.*
8
+ !.env.example
9
+ *.pem
10
+ *.key
11
+ .dev.vars
12
+ .dev.vars.*
13
+ secrets/
14
+ .cloudflare-token
15
+ .wrangler-token
16
+
17
+ # ── Local Cloudflare state ──────────────────────────────────
18
+ .wrangler/
19
+ wrangler.log
20
+ .cloudflared/
21
+
22
+ # ── Node ────────────────────────────────────────────────────
23
+ node_modules/
24
+ .npm/
25
+ .yarn/
26
+ .pnpm-store/
27
+ .pnp.*
28
+ npm-debug.log*
29
+ yarn-debug.log*
30
+ yarn-error.log*
31
+ pnpm-debug.log*
32
+ .turbo/
33
+
34
+ # ── TypeScript / build output ───────────────────────────────
35
+ dist/
36
+ build/
37
+ .next/
38
+ .nuxt/
39
+ *.tsbuildinfo
40
+
41
+ # ── Python (collector) ──────────────────────────────────────
42
+ __pycache__/
43
+ *.py[cod]
44
+ *$py.class
45
+ *.egg-info/
46
+ .eggs/
47
+ .venv/
48
+ venv/
49
+ env/
50
+ .pytest_cache/
51
+ .mypy_cache/
52
+ .ruff_cache/
53
+ .coverage
54
+ htmlcov/
55
+
56
+ # ── Supabase ────────────────────────────────────────────────
57
+ supabase/.temp/
58
+ supabase/.branches/
59
+
60
+ # ── Editor / OS ─────────────────────────────────────────────
61
+ .DS_Store
62
+ ._*
63
+ Thumbs.db
64
+ .idea/
65
+ .vscode/*
66
+ !.vscode/settings.example.json
67
+ *.swp
68
+ *.swo
69
+ *~
70
+ .history/
71
+
72
+ # ── Archives (snapshots — committed separately as tagged releases) ──
73
+ June 02 2026/**/Archive.zip
74
+ June 02 2026/developer-packet/Archive/
75
+ June 02 2026/developer-packet/code/node_modules/
76
+ June 02 2026/code/node_modules/
77
+
78
+ # ── Logs ────────────────────────────────────────────────────
79
+ *.log
80
+ logs/
81
+
82
+ # ── Test / coverage ─────────────────────────────────────────
83
+ coverage/
84
+ .nyc_output/
85
+
86
+ # ── Tmp ─────────────────────────────────────────────────────
87
+ tmp/
88
+ .tmp/
89
+ *.tmp
@@ -0,0 +1,222 @@
1
+ Metadata-Version: 2.4
2
+ Name: proofbench-collector
3
+ Version: 1.0.0
4
+ Summary: ProofBench — local network discovery collector. Wraps nmap + passive ARP/mDNS, signs the bundle locally, uploads to proofbench.io for cryptographic counter-signing.
5
+ Project-URL: Homepage, https://proofbench.io
6
+ Project-URL: Documentation, https://proofbench.io/about/architecture
7
+ Project-URL: Repository, https://github.com/proofbench/proofbench-collector
8
+ Project-URL: Issues, https://github.com/proofbench/proofbench-collector/issues
9
+ Author-email: "ProofBench, Inc." <rayve@eftconsultants.com>
10
+ License: Apache-2.0
11
+ Keywords: attestation,compliance,cyber-insurance,cybersecurity,mcp,network-discovery
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Topic :: Security
25
+ Requires-Python: >=3.9
26
+ Requires-Dist: requests<3.0,>=2.31
27
+ Provides-Extra: dev
28
+ Requires-Dist: mypy>=1.7; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=4.1; extra == 'dev'
30
+ Requires-Dist: pytest>=7.4; extra == 'dev'
31
+ Requires-Dist: ruff>=0.1; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Provelab Collector
35
+
36
+ Local network discovery for SMBs. Runs on your laptop, signs the evidence, uploads to proofbench.io.
37
+
38
+ **What it does in 90 seconds:** wraps `nmap` + passive ARP/mDNS observation, normalizes results into the Provelab Run/Asset/Evidence schema, signs the bundle with HMAC-SHA256 using your collector's enrollment token, and POSTs the signed bundle to proofbench.io. The cloud verifies the signature and renders your inventory + Coalition cyber-insurance renewal questionnaire.
39
+
40
+ **What it does NOT do:** initiate any scan from the cloud, collect default credentials, run exploits, scan anything outside the CIDR you authorize, store data anywhere except `~/.config/provelab/` locally and your authorized ProofBench cloud bucket.
41
+
42
+ ## Install
43
+
44
+ ### macOS
45
+
46
+ ```bash
47
+ brew install nmap
48
+ pipx install provelab-collector # or: pip install --user provelab-collector
49
+ ```
50
+
51
+ ### Linux (Debian / Ubuntu)
52
+
53
+ ```bash
54
+ sudo apt install nmap avahi-utils
55
+ pipx install provelab-collector # or: pip install --user provelab-collector
56
+ ```
57
+
58
+ ### Windows (via WSL — native Windows native binary in v1.1)
59
+
60
+ ```bash
61
+ # inside WSL Ubuntu
62
+ sudo apt install nmap
63
+ pipx install provelab-collector
64
+ ```
65
+
66
+ Verify:
67
+
68
+ ```bash
69
+ provelab --version
70
+ # provelab v0.0.1
71
+ ```
72
+
73
+ ## Quick start
74
+
75
+ ```bash
76
+ # 1. Enroll the collector with your ProofBench account
77
+ provelab enroll
78
+
79
+ # 2. Run a scan against your network
80
+ provelab scan 192.168.1.0/24
81
+
82
+ # 3. Upload the signed bundle to proofbench.io
83
+ provelab scan 192.168.1.0/24 --upload
84
+ ```
85
+
86
+ After `--upload`, your dashboard at https://proofbench.io/app updates within ~10 seconds and your Trust Center URL at `proofbench.io/trust/{your-slug}` shows the new posture.
87
+
88
+ ## Commands
89
+
90
+ ### `provelab enroll`
91
+
92
+ Pairs this collector with your ProofBench organization. Interactive — opens an enrollment URL, you sign in, paste the one-time token back into the terminal. The token is stored locally at `~/.config/provelab/config.json` with `0600` permissions.
93
+
94
+ ```bash
95
+ provelab enroll
96
+ provelab enroll --api https://proofbench.io # custom API base (default is proofbench.io)
97
+ ```
98
+
99
+ ### `provelab scan <cidr>`
100
+
101
+ Run a discovery scan against a CIDR.
102
+
103
+ ```bash
104
+ provelab scan 192.168.1.0/24 # default profile: iot_ot_cautious
105
+ provelab scan 10.0.0.0/16 --profile passive_only # passive observations only
106
+ provelab scan 192.168.1.0/24 --profile lab_permissive # broader probes (lab only)
107
+ provelab scan 192.168.1.0/24 --output run.json # save locally without uploading
108
+ provelab scan 192.168.1.0/24 --upload # sign + upload in one step
109
+ ```
110
+
111
+ **Scan profiles:**
112
+
113
+ | Profile | What it does | When to use |
114
+ | --- | --- | --- |
115
+ | `passive_only` | ARP + mDNS observation only. No active probes. | Quiet networks, sensitive OT environments, or pre-flight reconnaissance. |
116
+ | `iot_ot_cautious` *(default)* | Bounded probes: mDNS, SSDP, ICMP, selected TCP banners on common ports (22, 80, 443, 554, etc.). | Normal office and SMB networks. Safe for production. |
117
+ | `lab_permissive` | Broader TCP banner reads across more ports. Higher network activity. | Lab environments and explicit maintenance windows. **Do not use on sensitive production OT.** |
118
+
119
+ Each profile has a strict allowlist of nmap flags. The CLI rejects anything outside the allowlist — you can't accidentally invoke an aggressive scan.
120
+
121
+ ### `provelab status`
122
+
123
+ Show the current collector configuration.
124
+
125
+ ```bash
126
+ provelab status
127
+ # provelab v0.0.1
128
+ # api_base: https://proofbench.io
129
+ # collector_id: collector-acme-corp-laptop
130
+ # enrolled: yes
131
+ # config_path: /Users/you/.config/provelab/config.json
132
+ ```
133
+
134
+ ### `provelab verify <bundle.json>`
135
+
136
+ Verify the HMAC signature on a bundle file. Useful for offline review or for a customer to independently check that an uploaded bundle wasn't tampered with.
137
+
138
+ ```bash
139
+ provelab verify provelab-run-20260601-...json
140
+ # [provelab] ✓ signature valid
141
+ # run_id: run-20260601-...
142
+ # collector_id: collector-acme-corp-laptop
143
+ # completed_at: 2026-06-01T14:23:11Z
144
+ # bundle_sha256: a3f9b12e...
145
+ ```
146
+
147
+ ## What the bundle contains
148
+
149
+ The signed JSON has this shape (full schema in `fixture-network-v0.json`):
150
+
151
+ ```json
152
+ {
153
+ "version": "1.0.0",
154
+ "run_metadata": {
155
+ "run_id": "run-20260601-...",
156
+ "collector_id": "collector-acme-corp-laptop",
157
+ "profile": "iot_ot_cautious",
158
+ "scope": "192.168.1.0/24",
159
+ "started_at": "2026-06-01T14:22:11Z",
160
+ "completed_at": "2026-06-01T14:23:11Z",
161
+ "asset_count": 47,
162
+ "evidence_count": 132,
163
+ "needs_review_count": 3
164
+ },
165
+ "assets": [
166
+ {
167
+ "id": "asset-a3f9b12e",
168
+ "ip": "192.168.1.1",
169
+ "mac": "aa:bb:cc:00:00:01",
170
+ "hostname": "edge-firewall",
171
+ "vendor": "Fortinet",
172
+ "os_hint": "FortiOS 7.4.2",
173
+ "identity_class": "router-firewall",
174
+ "identity_label": "Edge firewall",
175
+ "confidence": 98,
176
+ "review_state": "accepted",
177
+ "review_reason": "normal",
178
+ "subnet": "192.168.1.0/24",
179
+ "open_ports": [22, 443],
180
+ "protocols_observed": ["ssh", "https", "snmp", "arp"],
181
+ "evidence_ids": ["ev-a3f9b12e-arp", "ev-a3f9b12e-p22", "..."],
182
+ "coalition_questions": ["Q22_internet_facing_inventory"]
183
+ }
184
+ ],
185
+ "signature": {
186
+ "version": "v1",
187
+ "bundle_sha256": "...",
188
+ "hmac_sha256": "..."
189
+ }
190
+ }
191
+ ```
192
+
193
+ ## Security notes
194
+
195
+ - **Your enrollment token never leaves your machine** except as the HMAC key used to sign bundles. The server stores only the SHA-256 hash of the token.
196
+ - **Bundles are signed locally before upload.** The signature binds the bundle hash to the collector ID, run ID, site ID, profile, and authorized scope. A signature for one bundle cannot be replayed against a different one.
197
+ - **The cloud cannot forge a signature.** It does not have your enrollment token, only its hash. Token compromise requires direct access to your laptop or your `~/.config/provelab/` directory.
198
+ - **Bundles can be verified offline.** `provelab verify <bundle.json>` re-runs the signature check locally. Anyone with the token (you) can verify; nobody else can.
199
+
200
+ ## Troubleshooting
201
+
202
+ **"nmap not found"** — install nmap via your package manager (see Install above).
203
+
204
+ **"Permission denied" on ARP scans** — nmap's `-PR` ARP discovery requires root. Run with `sudo provelab scan ...`. The scan profiles use SYN scans (also root-required on Linux) for similar reasons.
205
+
206
+ **Scan takes too long** — the `iot_ot_cautious` profile has a 3-minute timeout per /24. Larger CIDRs scale linearly. For /16 networks, expect ~10 minutes.
207
+
208
+ **"upload rejected: rate limit exceeded"** — Free Forever tier allows 1 attested run per month. Upgrade to Solo ($49/mo) for unlimited runs at https://proofbench.io/upgrade.
209
+
210
+ **"signature verification failed"** — your enrollment token may be invalid. Re-enroll with `provelab enroll`.
211
+
212
+ **No mDNS observations on macOS** — v0 doesn't parse macOS `dns-sd` output. mDNS enrichment requires `avahi-browse` (Linux). The scan still works; mDNS just doesn't enrich.
213
+
214
+ ## Source
215
+
216
+ Open source. Apache 2.0. https://github.com/proofbench/provelab-collector
217
+
218
+ Bug reports + security disclosures: rayve@eftconsultants.com
219
+
220
+ ---
221
+
222
+ *Provelab by ProofBench · provelab-collector v0.0.1 · The evidence layer for SMB cyber posture.*
@@ -0,0 +1,189 @@
1
+ # Provelab Collector
2
+
3
+ Local network discovery for SMBs. Runs on your laptop, signs the evidence, uploads to proofbench.io.
4
+
5
+ **What it does in 90 seconds:** wraps `nmap` + passive ARP/mDNS observation, normalizes results into the Provelab Run/Asset/Evidence schema, signs the bundle with HMAC-SHA256 using your collector's enrollment token, and POSTs the signed bundle to proofbench.io. The cloud verifies the signature and renders your inventory + Coalition cyber-insurance renewal questionnaire.
6
+
7
+ **What it does NOT do:** initiate any scan from the cloud, collect default credentials, run exploits, scan anything outside the CIDR you authorize, store data anywhere except `~/.config/provelab/` locally and your authorized ProofBench cloud bucket.
8
+
9
+ ## Install
10
+
11
+ ### macOS
12
+
13
+ ```bash
14
+ brew install nmap
15
+ pipx install provelab-collector # or: pip install --user provelab-collector
16
+ ```
17
+
18
+ ### Linux (Debian / Ubuntu)
19
+
20
+ ```bash
21
+ sudo apt install nmap avahi-utils
22
+ pipx install provelab-collector # or: pip install --user provelab-collector
23
+ ```
24
+
25
+ ### Windows (via WSL — native Windows native binary in v1.1)
26
+
27
+ ```bash
28
+ # inside WSL Ubuntu
29
+ sudo apt install nmap
30
+ pipx install provelab-collector
31
+ ```
32
+
33
+ Verify:
34
+
35
+ ```bash
36
+ provelab --version
37
+ # provelab v0.0.1
38
+ ```
39
+
40
+ ## Quick start
41
+
42
+ ```bash
43
+ # 1. Enroll the collector with your ProofBench account
44
+ provelab enroll
45
+
46
+ # 2. Run a scan against your network
47
+ provelab scan 192.168.1.0/24
48
+
49
+ # 3. Upload the signed bundle to proofbench.io
50
+ provelab scan 192.168.1.0/24 --upload
51
+ ```
52
+
53
+ After `--upload`, your dashboard at https://proofbench.io/app updates within ~10 seconds and your Trust Center URL at `proofbench.io/trust/{your-slug}` shows the new posture.
54
+
55
+ ## Commands
56
+
57
+ ### `provelab enroll`
58
+
59
+ Pairs this collector with your ProofBench organization. Interactive — opens an enrollment URL, you sign in, paste the one-time token back into the terminal. The token is stored locally at `~/.config/provelab/config.json` with `0600` permissions.
60
+
61
+ ```bash
62
+ provelab enroll
63
+ provelab enroll --api https://proofbench.io # custom API base (default is proofbench.io)
64
+ ```
65
+
66
+ ### `provelab scan <cidr>`
67
+
68
+ Run a discovery scan against a CIDR.
69
+
70
+ ```bash
71
+ provelab scan 192.168.1.0/24 # default profile: iot_ot_cautious
72
+ provelab scan 10.0.0.0/16 --profile passive_only # passive observations only
73
+ provelab scan 192.168.1.0/24 --profile lab_permissive # broader probes (lab only)
74
+ provelab scan 192.168.1.0/24 --output run.json # save locally without uploading
75
+ provelab scan 192.168.1.0/24 --upload # sign + upload in one step
76
+ ```
77
+
78
+ **Scan profiles:**
79
+
80
+ | Profile | What it does | When to use |
81
+ | --- | --- | --- |
82
+ | `passive_only` | ARP + mDNS observation only. No active probes. | Quiet networks, sensitive OT environments, or pre-flight reconnaissance. |
83
+ | `iot_ot_cautious` *(default)* | Bounded probes: mDNS, SSDP, ICMP, selected TCP banners on common ports (22, 80, 443, 554, etc.). | Normal office and SMB networks. Safe for production. |
84
+ | `lab_permissive` | Broader TCP banner reads across more ports. Higher network activity. | Lab environments and explicit maintenance windows. **Do not use on sensitive production OT.** |
85
+
86
+ Each profile has a strict allowlist of nmap flags. The CLI rejects anything outside the allowlist — you can't accidentally invoke an aggressive scan.
87
+
88
+ ### `provelab status`
89
+
90
+ Show the current collector configuration.
91
+
92
+ ```bash
93
+ provelab status
94
+ # provelab v0.0.1
95
+ # api_base: https://proofbench.io
96
+ # collector_id: collector-acme-corp-laptop
97
+ # enrolled: yes
98
+ # config_path: /Users/you/.config/provelab/config.json
99
+ ```
100
+
101
+ ### `provelab verify <bundle.json>`
102
+
103
+ Verify the HMAC signature on a bundle file. Useful for offline review or for a customer to independently check that an uploaded bundle wasn't tampered with.
104
+
105
+ ```bash
106
+ provelab verify provelab-run-20260601-...json
107
+ # [provelab] ✓ signature valid
108
+ # run_id: run-20260601-...
109
+ # collector_id: collector-acme-corp-laptop
110
+ # completed_at: 2026-06-01T14:23:11Z
111
+ # bundle_sha256: a3f9b12e...
112
+ ```
113
+
114
+ ## What the bundle contains
115
+
116
+ The signed JSON has this shape (full schema in `fixture-network-v0.json`):
117
+
118
+ ```json
119
+ {
120
+ "version": "1.0.0",
121
+ "run_metadata": {
122
+ "run_id": "run-20260601-...",
123
+ "collector_id": "collector-acme-corp-laptop",
124
+ "profile": "iot_ot_cautious",
125
+ "scope": "192.168.1.0/24",
126
+ "started_at": "2026-06-01T14:22:11Z",
127
+ "completed_at": "2026-06-01T14:23:11Z",
128
+ "asset_count": 47,
129
+ "evidence_count": 132,
130
+ "needs_review_count": 3
131
+ },
132
+ "assets": [
133
+ {
134
+ "id": "asset-a3f9b12e",
135
+ "ip": "192.168.1.1",
136
+ "mac": "aa:bb:cc:00:00:01",
137
+ "hostname": "edge-firewall",
138
+ "vendor": "Fortinet",
139
+ "os_hint": "FortiOS 7.4.2",
140
+ "identity_class": "router-firewall",
141
+ "identity_label": "Edge firewall",
142
+ "confidence": 98,
143
+ "review_state": "accepted",
144
+ "review_reason": "normal",
145
+ "subnet": "192.168.1.0/24",
146
+ "open_ports": [22, 443],
147
+ "protocols_observed": ["ssh", "https", "snmp", "arp"],
148
+ "evidence_ids": ["ev-a3f9b12e-arp", "ev-a3f9b12e-p22", "..."],
149
+ "coalition_questions": ["Q22_internet_facing_inventory"]
150
+ }
151
+ ],
152
+ "signature": {
153
+ "version": "v1",
154
+ "bundle_sha256": "...",
155
+ "hmac_sha256": "..."
156
+ }
157
+ }
158
+ ```
159
+
160
+ ## Security notes
161
+
162
+ - **Your enrollment token never leaves your machine** except as the HMAC key used to sign bundles. The server stores only the SHA-256 hash of the token.
163
+ - **Bundles are signed locally before upload.** The signature binds the bundle hash to the collector ID, run ID, site ID, profile, and authorized scope. A signature for one bundle cannot be replayed against a different one.
164
+ - **The cloud cannot forge a signature.** It does not have your enrollment token, only its hash. Token compromise requires direct access to your laptop or your `~/.config/provelab/` directory.
165
+ - **Bundles can be verified offline.** `provelab verify <bundle.json>` re-runs the signature check locally. Anyone with the token (you) can verify; nobody else can.
166
+
167
+ ## Troubleshooting
168
+
169
+ **"nmap not found"** — install nmap via your package manager (see Install above).
170
+
171
+ **"Permission denied" on ARP scans** — nmap's `-PR` ARP discovery requires root. Run with `sudo provelab scan ...`. The scan profiles use SYN scans (also root-required on Linux) for similar reasons.
172
+
173
+ **Scan takes too long** — the `iot_ot_cautious` profile has a 3-minute timeout per /24. Larger CIDRs scale linearly. For /16 networks, expect ~10 minutes.
174
+
175
+ **"upload rejected: rate limit exceeded"** — Free Forever tier allows 1 attested run per month. Upgrade to Solo ($49/mo) for unlimited runs at https://proofbench.io/upgrade.
176
+
177
+ **"signature verification failed"** — your enrollment token may be invalid. Re-enroll with `provelab enroll`.
178
+
179
+ **No mDNS observations on macOS** — v0 doesn't parse macOS `dns-sd` output. mDNS enrichment requires `avahi-browse` (Linux). The scan still works; mDNS just doesn't enrich.
180
+
181
+ ## Source
182
+
183
+ Open source. Apache 2.0. https://github.com/proofbench/provelab-collector
184
+
185
+ Bug reports + security disclosures: rayve@eftconsultants.com
186
+
187
+ ---
188
+
189
+ *Provelab by ProofBench · provelab-collector v0.0.1 · The evidence layer for SMB cyber posture.*
@@ -0,0 +1,135 @@
1
+ # ============================================================================
2
+ # Provelab by ProofBench - one-line installer for Windows (PowerShell 5.1+)
3
+ #
4
+ # Usage (interactive, from an elevated PowerShell prompt):
5
+ # irm https://proofbench.io/install.ps1 | iex
6
+ #
7
+ # Usage (non-interactive, with token from the dashboard):
8
+ # $env:PROOFBENCH_TOKEN = "provelab_enroll_xxx"
9
+ # $env:PROOFBENCH_COLLECTOR_ID = "collector-xxx"
10
+ # irm https://proofbench.io/install.ps1 | iex
11
+ #
12
+ # What this does:
13
+ # 1. Verifies PowerShell 5.1+ and admin rights.
14
+ # 2. Installs nmap and Python via winget (or scoop fallback).
15
+ # 3. Installs the provelab CLI via pip --user.
16
+ # 4. If $env:PROOFBENCH_TOKEN is set, enrolls non-interactively.
17
+ # 5. Optionally registers a daily scheduled task. Controlled by
18
+ # $env:PROOFBENCH_INSTALL_SERVICE = "1" (default: off; opt-in).
19
+ # ============================================================================
20
+
21
+ $ErrorActionPreference = "Stop"
22
+
23
+ function Write-Step { param($msg) Write-Host "[provelab-install] $msg" -ForegroundColor DarkGray }
24
+ function Write-OK { param($msg) Write-Host "OK $msg" -ForegroundColor Green }
25
+ function Write-Warn2 { param($msg) Write-Host "! $msg" -ForegroundColor Yellow }
26
+ function Write-Fail { param($msg) Write-Host "X $msg" -ForegroundColor Red }
27
+
28
+ Write-Host ""
29
+ Write-Host " Provelab by ProofBench - collector installer" -ForegroundColor White
30
+ Write-Host " This script installs nmap, Python, and the provelab CLI." -ForegroundColor DarkGray
31
+ Write-Host ""
32
+
33
+ # ----- pre-flight -----------------------------------------------------------
34
+ if ($PSVersionTable.PSVersion.Major -lt 5) {
35
+ Write-Fail "PowerShell 5.1 or newer required. Current: $($PSVersionTable.PSVersion)"
36
+ exit 1
37
+ }
38
+
39
+ $isAdmin = ([Security.Principal.WindowsPrincipal] `
40
+ [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
41
+ [Security.Principal.WindowsBuiltInRole]::Administrator)
42
+
43
+ if (-not $isAdmin) {
44
+ Write-Warn2 "Not running as Administrator. Some installs may fail."
45
+ Write-Warn2 "Right-click PowerShell -> Run as Administrator, then re-run."
46
+ Start-Sleep -Seconds 2
47
+ }
48
+
49
+ # ----- nmap install ---------------------------------------------------------
50
+ if (Get-Command nmap -ErrorAction SilentlyContinue) {
51
+ Write-OK "nmap already installed"
52
+ } else {
53
+ Write-Step "Installing nmap..."
54
+ if (Get-Command winget -ErrorAction SilentlyContinue) {
55
+ winget install --silent --accept-package-agreements --accept-source-agreements --id Insecure.Nmap
56
+ } elseif (Get-Command scoop -ErrorAction SilentlyContinue) {
57
+ scoop install nmap
58
+ } else {
59
+ Write-Fail "Neither winget nor scoop is installed. Install nmap manually from https://nmap.org/download.html then re-run."
60
+ exit 2
61
+ }
62
+ Write-OK "nmap installed"
63
+ }
64
+
65
+ # ----- python install -------------------------------------------------------
66
+ if (Get-Command python -ErrorAction SilentlyContinue) {
67
+ Write-OK "Python already installed: $(python --version 2>&1)"
68
+ } else {
69
+ Write-Step "Installing Python..."
70
+ if (Get-Command winget -ErrorAction SilentlyContinue) {
71
+ winget install --silent --accept-package-agreements --accept-source-agreements --id Python.Python.3.12
72
+ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + `
73
+ [System.Environment]::GetEnvironmentVariable("Path","User")
74
+ } else {
75
+ Write-Fail "Install Python 3.10+ from https://python.org/downloads then re-run."
76
+ exit 2
77
+ }
78
+ Write-OK "Python installed"
79
+ }
80
+
81
+ # ----- provelab install -----------------------------------------------------
82
+ Write-Step "Installing provelab-collector via pip..."
83
+ python -m pip install --user --upgrade pip --quiet
84
+ python -m pip install --user --upgrade provelab-collector --quiet
85
+ if ($LASTEXITCODE -ne 0) {
86
+ Write-Fail "pip install provelab-collector failed."
87
+ exit 3
88
+ }
89
+ Write-OK "provelab CLI installed"
90
+
91
+ # Make sure %APPDATA%\Python\Scripts is on PATH for this session.
92
+ $userScripts = "$env:APPDATA\Python\Python312\Scripts"
93
+ if (Test-Path $userScripts) { $env:Path = "$userScripts;$env:Path" }
94
+
95
+ provelab --version
96
+
97
+ # ----- enroll ---------------------------------------------------------------
98
+ $tok = $env:PROOFBENCH_TOKEN
99
+ $cid = $env:PROOFBENCH_COLLECTOR_ID
100
+ $api = if ($env:PROOFBENCH_API) { $env:PROOFBENCH_API } else { "https://proofbench.io" }
101
+
102
+ if ($tok -and $cid) {
103
+ Write-Step "Enrolling non-interactively..."
104
+ provelab enroll --token $tok --collector-id $cid --api $api
105
+ if ($LASTEXITCODE -ne 0) {
106
+ Write-Fail "Enrollment failed. Re-issue the token in your dashboard."
107
+ exit 4
108
+ }
109
+ Write-OK "Collector enrolled"
110
+ } else {
111
+ Write-Host ""
112
+ Write-Warn2 "No PROOFBENCH_TOKEN provided. To finish setup, run:"
113
+ Write-Host " provelab enroll" -ForegroundColor White
114
+ Write-Host " and paste the token from https://proofbench.io/app/collectors"
115
+ }
116
+
117
+ # ----- optional scheduled task ---------------------------------------------
118
+ if ($env:PROOFBENCH_INSTALL_SERVICE -eq "1") {
119
+ Write-Step "Registering daily scheduled scan..."
120
+ $cidr = if ($env:PROOFBENCH_DEFAULT_CIDR) { $env:PROOFBENCH_DEFAULT_CIDR } else { "192.168.1.0/24" }
121
+ provelab install-service --cidr $cidr
122
+ if ($LASTEXITCODE -ne 0) {
123
+ Write-Warn2 "Scheduled task registration failed. Run scans manually with: provelab scan <cidr>"
124
+ } else {
125
+ Write-OK "Scheduled task registered (runs daily at 03:00)"
126
+ }
127
+ }
128
+
129
+ Write-Host ""
130
+ Write-Host " Installation complete." -ForegroundColor Green
131
+ Write-Host ""
132
+ Write-Host " Next steps:"
133
+ Write-Host " provelab scan 192.168.1.0/24 --upload"
134
+ Write-Host " Open https://proofbench.io/app to see your inventory."
135
+ Write-Host ""