@slicedearth/whoisleuth-cli 1.39.1 → 1.43.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.
Files changed (66) hide show
  1. package/README.md +15 -0
  2. package/bin/whoisleuth.mjs +13 -2
  3. package/cli/archive-inspect.mjs +37 -2
  4. package/cli/arguments.mjs +361 -256
  5. package/cli/artifact-verify.mjs +35 -1
  6. package/cli/bulk-checkpoint.mjs +7 -11
  7. package/cli/bulk-command-runner.mjs +19 -2
  8. package/cli/case-pack.mjs +136 -0
  9. package/cli/ci-report.mjs +73 -0
  10. package/cli/collection-preflight.mjs +59 -0
  11. package/cli/command-reference.mjs +395 -0
  12. package/cli/completion.mjs +33 -10
  13. package/cli/config-profile.mjs +180 -0
  14. package/cli/ct-event-intake.mjs +159 -0
  15. package/cli/discovery-scan-command-runner.mjs +15 -1
  16. package/cli/domain-control-monitor.mjs +104 -0
  17. package/cli/domain-control-observations.mjs +235 -0
  18. package/cli/evidence-command-arguments.mjs +11 -0
  19. package/cli/evidence-command-runner.mjs +1 -0
  20. package/cli/external-observation-mapping.mjs +162 -0
  21. package/cli/fail-policy.mjs +64 -0
  22. package/cli/formatters/html.mjs +1 -1
  23. package/cli/investigation-manifest.mjs +113 -0
  24. package/cli/investigation-run.mjs +112 -0
  25. package/cli/lookup-brief.mjs +116 -0
  26. package/cli/lookup-command-runner.mjs +8 -1
  27. package/cli/lookup-diff.mjs +17 -19
  28. package/cli/network-command-runner.mjs +4 -1
  29. package/cli/offline-evidence-review.mjs +105 -8
  30. package/cli/open-asset-model-bridge.mjs +169 -0
  31. package/cli/registry-cohort.mjs +121 -0
  32. package/cli/registry-doctor.mjs +106 -11
  33. package/cli/registry-fixture-scaffold.mjs +73 -0
  34. package/cli/runner.mjs +368 -306
  35. package/docs/cli-reference.md +240 -14
  36. package/docs/cli.md +42 -7
  37. package/frontend/src/lib/analysis/acquisition-due-diligence.js +1 -1
  38. package/frontend/src/lib/analysis/brand-profile-model.js +46 -4
  39. package/frontend/src/lib/analysis/case-report.js +573 -0
  40. package/frontend/src/lib/analysis/case-response-model.js +30 -1
  41. package/frontend/src/lib/analysis/detection-rule-model.js +36 -0
  42. package/frontend/src/lib/analysis/external-findings-import.js +320 -0
  43. package/frontend/src/lib/analysis/lookup-decision-support.js +7 -0
  44. package/frontend/src/lib/analysis/lookup-presentation.js +10 -20
  45. package/frontend/src/lib/analysis/scoring.js +1 -1
  46. package/frontend/src/lib/analysis/visualization-models.js +2 -3
  47. package/frontend/src/lib/analysis/workspace-archive.js +2 -0
  48. package/lib/abusech-auth.mjs +1 -1
  49. package/lib/availability.mjs +1 -1
  50. package/lib/bounded-contract-normalizers.mjs +33 -0
  51. package/lib/dns-convergence-review.mjs +183 -0
  52. package/lib/dns-delegation-health.mjs +196 -3
  53. package/lib/domain-change-packet.mjs +133 -0
  54. package/lib/domain-change-review.mjs +307 -0
  55. package/lib/domain-control-flight-recorder.mjs +268 -0
  56. package/lib/domain-portfolio-review.mjs +151 -0
  57. package/lib/evidence-export.mjs +1 -1
  58. package/lib/html-signals.mjs +5 -11
  59. package/lib/nameserver-preflight-review.mjs +159 -0
  60. package/lib/page-language-signals.mjs +124 -0
  61. package/lib/risk-scoring.mjs +42 -1
  62. package/lib/static-html-analysis.mjs +29 -1
  63. package/lib/trust-store-comparison.mjs +146 -0
  64. package/lib/website-technology.mjs +24 -10
  65. package/lib/zone-intent-review.mjs +534 -0
  66. package/package.json +1 -1
package/cli/runner.mjs CHANGED
@@ -6,6 +6,7 @@ import { REGISTRY_CAPABILITIES_VERSION, registryCapabilityFor } from "../lib/reg
6
6
  import { explainRiskScore, explainRiskScoreV6, RISK_MODEL_VERSION, RISK_REVIEW_THRESHOLD } from "../lib/risk-scoring.mjs";
7
7
  import { CLI_COMMANDS, parseCliArguments } from "./arguments.mjs";
8
8
  import { buildCliCommandCatalogue, formatCliCommandCatalogue } from "./command-catalogue.mjs";
9
+ import { COMMAND_COLLECTION, COMMAND_DETAILS, COMMAND_USAGE, HELP, commandHelp, } from "./command-reference.mjs";
9
10
  import { buildShellCompletion } from "./completion.mjs";
10
11
  import { buildDoctorReport, formatDoctorReport } from "./doctor.mjs";
11
12
  import { MAX_COMPARE_INPUT_BYTES, compareLookupDocument, parseCliLookupDocument, readCompareInputBounded, } from "./compare.mjs";
@@ -25,14 +26,28 @@ import { buildCliPageComparison, formatCliPageComparison } from "./page-compare.
25
26
  import { MAX_MAIL_REVIEW_INPUT_BYTES, buildCliMailReview, formatCliMailReview, } from "./mail-review.mjs";
26
27
  import { MAX_OFFLINE_EVIDENCE_INPUT_BYTES, buildOfflineEvidenceReview, buildOfflineEvidenceReviewWithLocalResources, formatOfflineEvidenceReview, } from "./offline-evidence-review.mjs";
27
28
  import { DOMAIN_CONTROL_MANIFEST_INPUT_SCHEMA, DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA, buildDomainControlManifest, formatDomainControlResult, reviewDomainControlManifest, } from "../lib/domain-control-manifest.mjs";
29
+ import { DOMAIN_CONTROL_FLIGHT_RECORDER_INPUT_SCHEMA, buildDomainControlFlightRecorder, formatDomainControlFlightRecorder, } from "../lib/domain-control-flight-recorder.mjs";
30
+ import { CLI_DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA, buildCliDomainControlReview, formatCliDomainControlReview, } from "./domain-control-observations.mjs";
31
+ import { buildCliLookupBrief, formatCliLookupBrief } from "./lookup-brief.mjs";
32
+ import { buildCliCasePack, formatCliCasePack } from "./case-pack.mjs";
33
+ import { formatDomainControlMonitor, runDomainControlMonitor } from "./domain-control-monitor.mjs";
28
34
  import { MAX_ASSURANCE_INPUT_BYTES, buildDomainAssurance, formatDomainAssurance, } from "../lib/domain-assurance.mjs";
35
+ import { MAX_DOMAIN_CHANGE_PACKET_INPUT_BYTES, buildDomainChangePacket, formatDomainChangePacket, } from "../lib/domain-change-packet.mjs";
29
36
  import { buildCliManual } from "./manual.mjs";
37
+ import { MAX_INVESTIGATION_MANIFEST_ARTIFACT_BYTES, buildInvestigationManifest, formatInvestigationManifest, } from "./investigation-manifest.mjs";
38
+ import { MAX_EXTERNAL_OBSERVATION_MAPPING_BYTES, mapExternalObservations, formatExternalObservationMapping, } from "./external-observation-mapping.mjs";
39
+ import { buildOpenAssetModelBridge, formatOpenAssetModelBridge, } from "./open-asset-model-bridge.mjs";
40
+ import { MAX_CT_EVENT_INPUT_BYTES, buildCtEventFindings, formatCtEventFindings, } from "./ct-event-intake.mjs";
30
41
  import { buildInvestigationPlan, formatInvestigationPlan } from "./investigation-plan.mjs";
31
- import { WHOISLEUTH_SOURCE_REPOSITORY_URL } from "../lib/project-metadata.mjs";
42
+ import { formatInvestigationRun, runInvestigationRecipe } from "./investigation-run.mjs";
43
+ import { evaluateCliFailPolicies, formatFailPolicyNotice } from "./fail-policy.mjs";
44
+ import { formatCliJunit } from "./ci-report.mjs";
32
45
  import { createBufferedOutput, writePrivateFile } from "./output-file.mjs";
33
46
  import { createTerminalProgress } from "./progress.mjs";
34
47
  import { buildRegistrySupportDocument } from "./registry-support.mjs";
35
48
  import { buildRegistryDoctorReport, formatRegistryDoctorReport } from "./registry-doctor.mjs";
49
+ import { MAX_REGISTRY_COHORT_INPUT_BYTES, buildRegistryCohortReport, formatRegistryCohortReport, } from "./registry-cohort.mjs";
50
+ import { buildRegistryFixtureScaffold } from "./registry-fixture-scaffold.mjs";
36
51
  import { MAX_OFFLINE_ARTIFACT_BYTES, MAX_OFFLINE_PASSPHRASE_FILE_BYTES, formatOfflineArtifactVerification, verifyOfflineArtifact, } from "./artifact-verify.mjs";
37
52
  import { MAX_SOURCE_RELIABILITY_INPUT_BYTES, buildSourceReliabilityReport, formatSourceReliabilityReport, } from "./source-reliability.mjs";
38
53
  import { MAX_RISK_CALIBRATION_INPUT_BYTES, buildRiskCalibrationReport, parseRiskCalibrationDataset, readRiskCalibrationInputBounded, } from "./risk-calibration.mjs";
@@ -42,308 +57,6 @@ import { presentTerminalOutput, terminalPresentation, } from "./terminal-present
42
57
  const require = createRequire(import.meta.url);
43
58
  const { version: VERSION } = require('../package.json');
44
59
  const MAX_STDIN_BYTES = 4096;
45
- const HELP = `WHOISleuth CLI
46
- Source-aware domain investigation from your terminal.
47
-
48
- Quick start:
49
- whoisleuth lookup example.test
50
- whoisleuth lookup example.test --deep
51
- cat domains.txt | whoisleuth bulk --jsonl
52
-
53
- Investigate:
54
- lookup Collect one domain, IP, or ASN.
55
- bulk Triage newline-delimited targets with bounded concurrency.
56
- http Inspect one homepage request and redirect chain.
57
- tls Inspect one hostname's current certificate connection.
58
- posture Review DNS mail and domain-control posture.
59
-
60
- Discover:
61
- ct-search Search certificate-transparency observations.
62
- discover Generate offline lookalike candidates.
63
- discover-scan Collect a bounded candidate review queue.
64
- registry-support Explain local registry coverage without a request.
65
- registry-doctor Diagnose a saved registry collection against local policy.
66
-
67
- Review saved evidence:
68
- source-report Summarise source reliability without retaining targets.
69
- compare Compare saved registry publications.
70
- page-compare Compare saved static page and TLS evidence.
71
- mail-review Review saved passive mail exposure evidence.
72
- review-evidence Review supplied DNS, routing, GeoIP, or RDAP evidence offline.
73
- domain-control Build or review an integrity-protected desired-state manifest.
74
- assurance Review change, recovery, concentration, or retirement plans.
75
- sharing-review Lint a reviewed artifact before deliberate sharing.
76
- workflow-plan Plan a fixed investigation recipe without executing it.
77
- diff Compare two saved domain observations.
78
- reconcile Reconcile independently labelled observations.
79
- timeline Compare a sequence of observations for one domain.
80
- export Convert a saved lookup into an evidence report.
81
- inspect-archive Inspect a workspace archive, redacted by default.
82
- verify-artifact Validate saved evidence or an integrity envelope offline.
83
-
84
- Integrity and calibration:
85
- sign-artifact Sign one reviewed packet or manifest locally.
86
- verify-signature Verify one signed evidence package locally.
87
- risk-calibrate Replay reviewed labels without changing the model.
88
- lookalike-calibrate Summarise reviewed mutation-family yield without tuning generation.
89
-
90
- Terminal:
91
- doctor Check the local runtime; network tests require --network.
92
- commands List command contracts for people or local tooling.
93
- completion Print completion for bash, zsh, fish, or PowerShell.
94
- manual Print the generated manual page.
95
-
96
- Run "whoisleuth <command> --help" for focused usage and an example.
97
- Use --json or --jsonl where supported for machine-readable stdout.
98
- Use --output <file> for atomic private file output and --force to replace it.
99
- Diagnostics are written to stderr. Fast lookup is the default; deep collection
100
- must be requested explicitly and can disclose a target to additional sources.
101
-
102
- Copyright 2026 slicedearth. Licensed under AGPL-3.0-only.
103
- Source and licence: ${WHOISLEUTH_SOURCE_REPOSITORY_URL}
104
- `;
105
- const COMMAND_USAGE = Object.freeze({
106
- completion: 'whoisleuth completion <bash|zsh|fish|powershell>',
107
- doctor: 'whoisleuth doctor [--network] [--json] [--quiet] [--no-color]',
108
- commands: 'whoisleuth commands [--json] [--quiet] [--no-color]',
109
- manual: 'whoisleuth manual',
110
- lookup: 'whoisleuth lookup <domain|IP|ASN> [--json|--markdown|--html] [--fast|--deep] [--observer <label>] [--vantage <label>] [--plan] [--summary|--verbose] [--strict-exit] [--events] [--quiet] [--no-color]',
111
- bulk: 'whoisleuth bulk [file] [--json|--jsonl|--csv|--domains|--queries] [--registered-only|--inconclusive-only|--errors-only] [--fast|--deep] [--concurrency <1-8>] [--checkpoint <file> [--resume]] [--events]',
112
- 'ct-search': 'whoisleuth ct-search <keyword> [--json] [--quiet] [--no-color]',
113
- discover: 'whoisleuth discover <brand|domain> [--tlds <list>] [--preset <name>|--families <ids>] [--keyboard <layout>] [--dictionary <file>] [--snapshot <file>] [--json|--jsonl|--domains]',
114
- 'discover-scan': 'whoisleuth discover-scan <brand|domain> [--fast|--deep] [--scan-limit <n>] [--chunk-size <n>] [--concurrency <n>] [--resolver <IPs>] [--allowlist <file>] [--checkpoint <file> [--resume]] [--observation-snapshot <file>] [--json|--jsonl|--csv|--domains]',
115
- posture: 'whoisleuth posture <domain> [--selectors <list>] [--retired-selectors <list>] [--mail-profile <profile>] [--json] [--quiet] [--no-color]',
116
- http: 'whoisleuth http <domain> [--json] [--quiet] [--no-color]',
117
- tls: 'whoisleuth tls <hostname> [--json] [--quiet] [--no-color]',
118
- 'registry-support': 'whoisleuth registry-support <domain|suffix> [--json] [--quiet] [--no-color]',
119
- 'registry-doctor': 'whoisleuth registry-doctor [lookup.json] [--json] [--quiet] [--no-color]',
120
- 'risk-calibrate': 'whoisleuth risk-calibrate [dataset.json] [--json] [--quiet] [--no-color]',
121
- 'lookalike-calibrate': 'whoisleuth lookalike-calibrate [dataset.json] [--json] [--quiet] [--no-color]',
122
- 'verify-artifact': 'whoisleuth verify-artifact [artifact.json] [--passphrase-file <file>] [--json] [--quiet] [--no-color]',
123
- 'inspect-archive': 'whoisleuth inspect-archive [archive.json] [--passphrase-file <file>] [--search <value>] [--require-match] [--reveal] [--json]',
124
- 'sign-artifact': 'whoisleuth sign-artifact [artifact.json] --private-key-file <file>',
125
- 'verify-signature': 'whoisleuth verify-signature [package.json] [--public-key-file <file>] [--json] [--quiet] [--no-color]',
126
- 'source-report': 'whoisleuth source-report [lookup.json] [--json] [--quiet] [--no-color]',
127
- compare: 'whoisleuth compare [lookup.json] [--json] [--quiet] [--no-color]',
128
- 'page-compare': 'whoisleuth page-compare <left.json> <right.json> [--json] [--quiet] [--no-color]',
129
- 'mail-review': 'whoisleuth mail-review [bulk.json|bulk.jsonl] [--json] [--quiet] [--no-color]',
130
- 'review-evidence': 'whoisleuth review-evidence [evidence.json] [--mmdb <database-file>] [--json] [--quiet] [--no-color]',
131
- 'domain-control': 'whoisleuth domain-control [manifest-input.json|review-input.json] [--json] [--quiet] [--no-color]',
132
- assurance: 'whoisleuth assurance [assurance-input.json] [--json] [--quiet] [--no-color]',
133
- 'sharing-review': 'whoisleuth sharing-review [artifact.json] --marking <level> --recipient-scope <scope> --purpose <text> [--human-reviewed] [--personal-data-reviewed] [--redactions-confirmed] [--json]',
134
- 'workflow-plan': 'whoisleuth workflow-plan <recipe> <domain|brand> [--json] [--quiet] [--no-color]',
135
- diff: 'whoisleuth diff <left.json> <right.json> [--json] [--quiet] [--no-color]',
136
- reconcile: 'whoisleuth reconcile <observation.json> <observation.json> [...] [--json] [--quiet] [--no-color]',
137
- timeline: 'whoisleuth timeline <observation.json> <observation.json> [...] [--json] [--quiet] [--no-color]',
138
- export: 'whoisleuth export [lookup.json] [--markdown|--html|--compact]',
139
- });
140
- const COMMAND_DETAILS = Object.freeze({
141
- completion: {
142
- description: 'Print a static shell-completion script for the installed CLI.',
143
- example: 'whoisleuth completion zsh > ~/.zfunc/_whoisleuth',
144
- boundary: 'Generation is offline and writes only the script to stdout. The command never modifies shell configuration.',
145
- },
146
- doctor: {
147
- description: 'Check the supported runtime and local terminal capabilities.',
148
- example: 'whoisleuth doctor --json',
149
- boundary: 'The default check is offline. Public DNS and port 43 checks run only when --network is explicitly supplied.',
150
- },
151
- commands: {
152
- description: 'List the installed command contracts in terminal or versioned JSON form.',
153
- example: 'whoisleuth commands --json',
154
- boundary: 'Catalogue generation is offline. It reports declared command modes and limits without executing collection or inspecting local evidence.',
155
- },
156
- manual: {
157
- description: 'Print a generated roff manual page for local installation.',
158
- example: 'whoisleuth manual | man -l -',
159
- boundary: 'Generation is offline and derives from the same command catalogue as focused help.',
160
- },
161
- lookup: {
162
- description: 'Collect registration evidence for one domain, IP, or ASN.',
163
- example: 'whoisleuth lookup example.test --deep',
164
- boundary: 'Fast is the default. Deep mode adds bounded WHOIS, DNS, HTTP, TLS, technology, posture, and network context where applicable.',
165
- },
166
- bulk: {
167
- description: 'Triage newline-delimited domains, IPs, or ASNs with bounded concurrency.',
168
- example: 'cat domains.txt | whoisleuth bulk --jsonl',
169
- boundary: 'Fast and deep jobs use separate concurrency ceilings. Filters affect output only; collection failures and inconclusive authority states remain explicit in JSON, JSONL, and CSV.',
170
- },
171
- 'ct-search': {
172
- description: 'Search certificate-transparency observations for one bounded keyword.',
173
- example: 'whoisleuth ct-search "example brand" --json',
174
- boundary: 'Certificate observations do not prove website activity, registration ownership, or malicious intent.',
175
- },
176
- discover: {
177
- description: 'Generate bounded lookalike-domain candidates from local mutation rules.',
178
- example: 'whoisleuth discover example.test --preset common --jsonl',
179
- boundary: 'Generation and optional local snapshot comparison are offline. Candidates are leads only and are not resolved, registered, or classified as malicious.',
180
- },
181
- 'discover-scan': {
182
- description: 'Generate a bounded candidate set, collect a selected subset, and produce a supervised review queue.',
183
- example: 'whoisleuth discover-scan example.test --scan-limit 50 --checkpoint scan.json --json',
184
- boundary: 'This command performs network collection. Fast compact lookup is the default; deep mode is capped at 50 candidates. Allowlisting changes review priority only and shared infrastructure remains a lead, not attribution.',
185
- },
186
- posture: {
187
- description: 'Review bounded DNS mail, delegation, and domain-control posture.',
188
- example: 'whoisleuth posture example.test --mail-profile standard --json',
189
- boundary: 'Missing or failed DNS observations remain inconclusive and are not reported as absent controls.',
190
- },
191
- http: {
192
- description: 'Inspect one homepage request, redirects, and bounded response metadata.',
193
- example: 'whoisleuth http example.test --json',
194
- boundary: 'Requests use the shared public-address and redirect guards. This is not a rendered browser or vulnerability scan.',
195
- },
196
- tls: {
197
- description: 'Inspect one hostname certificate through a bounded TLS connection.',
198
- example: 'whoisleuth tls example.test --json',
199
- boundary: 'One observed connection is point-in-time evidence and does not establish every address, edge, or historical certificate.',
200
- },
201
- 'registry-support': {
202
- description: 'Explain the local registry capability profile for one domain or suffix.',
203
- example: 'whoisleuth registry-support example.test --json',
204
- boundary: 'This command is offline. Catalogue coverage does not test live reachability or decide registration or availability.',
205
- },
206
- 'registry-doctor': {
207
- description: 'Compare a saved Lookup registry result with the reviewed local capability profile.',
208
- example: 'whoisleuth registry-doctor lookup.json --json',
209
- boundary: 'The command is offline. It distinguishes expected access constraints from collection results and does not contact a live registry.',
210
- },
211
- 'risk-calibrate': {
212
- description: 'Replay reviewed labels against the current explainable Risk model.',
213
- example: 'whoisleuth risk-calibrate calibration.json --json',
214
- boundary: 'Calibration is offline and diagnostic. It never trains, tunes, or changes the scoring model automatically.',
215
- },
216
- 'lookalike-calibrate': {
217
- description: 'Summarise reviewed candidate dispositions by mutation family without retaining domains.',
218
- example: 'whoisleuth lookalike-calibrate reviewed-candidates.json --json',
219
- boundary: 'Calibration is offline and diagnostic. It omits candidate identifiers, domains, notes, and evidence and never tunes generation or filtering automatically.',
220
- },
221
- 'verify-artifact': {
222
- description: 'Validate a supported archive, packet, manifest, or saved Lookup without printing evidence contents.',
223
- example: 'whoisleuth verify-artifact workspace.json --json',
224
- boundary: 'Verification is offline and redacted. Encrypted archives require an explicitly supplied passphrase file.',
225
- },
226
- 'inspect-archive': {
227
- description: 'Summarise or search one workspace archive with redacted output by default.',
228
- example: 'whoisleuth inspect-archive workspace.json --search example.test --json',
229
- boundary: 'Exact matches require --reveal. The archive is read locally and is never uploaded.',
230
- },
231
- 'sign-artifact': {
232
- description: 'Sign one reviewed response packet or supported manifest with a local private key.',
233
- example: 'whoisleuth sign-artifact packet.json --private-key-file analyst-private.pem',
234
- boundary: 'The command never creates, stores, or transmits keys. Key custody and signer identity remain the operator\'s responsibility.',
235
- },
236
- 'verify-signature': {
237
- description: 'Verify the integrity and signature of one signed evidence package.',
238
- example: 'whoisleuth verify-signature packet.signed.json --json',
239
- boundary: 'A valid signature proves package consistency for the embedded key, not the real-world identity or authority of its holder.',
240
- },
241
- 'source-report': {
242
- description: 'Create a target-free reliability summary from a saved lookup.',
243
- example: 'whoisleuth source-report lookup.json --json',
244
- boundary: 'The report retains source states and timings but excludes targets, queries, endpoints, and raw evidence.',
245
- },
246
- compare: {
247
- description: 'Compare separately attributed registry publications in a saved lookup.',
248
- example: 'whoisleuth compare lookup.json --json',
249
- boundary: 'Comparison is offline. Differences are review context and do not by themselves prove which publication is current.',
250
- },
251
- 'page-compare': {
252
- description: 'Compare static page identity, favicon, technology, and TLS evidence in two saved deep lookups.',
253
- example: 'whoisleuth page-compare official.json candidate.json --json',
254
- boundary: 'Comparison is offline and component-based. It executes no page code and produces no aggregate similarity or maliciousness score.',
255
- },
256
- 'mail-review': {
257
- description: 'Review passive MX, null MX, SPF, DMARC, and shared mail-provider evidence from saved Bulk results.',
258
- example: 'whoisleuth mail-review candidates.json --json',
259
- boundary: 'Review is offline and sends no SMTP traffic. Missing or partial DNS evidence remains inconclusive.',
260
- },
261
- 'review-evidence': {
262
- description: 'Review one versioned DNSSEC, TLSA, RPKI, GeoIP, encrypted-DNS, or RDAP planning document offline.',
263
- example: 'whoisleuth review-evidence dnssec-evidence.json --json',
264
- boundary: 'The command reads only the supplied document. It performs no DNS, RDAP, BGP, GeoIP-provider, TLS, HTTP, or SMTP request.',
265
- },
266
- 'domain-control': {
267
- description: 'Build an integrity-protected desired-state manifest or compare one with supplied observations.',
268
- example: 'whoisleuth domain-control domain-control-input.json --json',
269
- boundary: 'The command is offline and changes no registrar, DNS, mail, or certificate configuration. Only complete supplied observations can produce drift.',
270
- },
271
- assurance: {
272
- description: 'Review a versioned domain change, recovery-dependency, or retirement plan.',
273
- example: 'whoisleuth assurance domain-assurance.json --json',
274
- boundary: 'The command is offline and treats every provider label, readiness state, and evidence reference as analyst-authored input. It changes no configuration.',
275
- },
276
- 'sharing-review': {
277
- description: 'Lint one reviewed artefact against local integrity, marking, recipient, personal-data, and redaction controls.',
278
- example: 'whoisleuth sharing-review packet.json --marking amber --recipient-scope organization --purpose "Reviewed incident handoff" --human-reviewed --personal-data-reviewed --redactions-confirmed --json',
279
- boundary: 'The command is offline and emits only bounded schema/version metadata, no content values, and no raw evidence. Its result is a review aid, not legal advice or recipient authorisation.',
280
- },
281
- 'workflow-plan': {
282
- description: 'Build a fixed domain-investigation plan from existing bounded CLI commands.',
283
- example: 'whoisleuth workflow-plan domain-triage example.test --json',
284
- boundary: 'Planning is offline and plan-only. It does not execute commands, expand placeholders, read files, make requests, or submit evidence.',
285
- },
286
- diff: {
287
- description: 'Compare bounded evidence retained in two saved domain lookups.',
288
- example: 'whoisleuth diff first.json second.json --json',
289
- boundary: 'Comparison is offline. Missing, unavailable, equal, and different evidence remain separate states.',
290
- },
291
- reconcile: {
292
- description: 'Reconcile bounded values across independently labelled observations of one domain.',
293
- example: 'whoisleuth reconcile office.json mobile.json external.json --json',
294
- boundary: 'The command is offline, accepts 2 to 5 saved observations for one domain, and never treats labels as proof of network independence or majority agreement as truth.',
295
- },
296
- timeline: {
297
- description: 'Build an ordered same-domain history from saved Lookup observations.',
298
- example: 'whoisleuth timeline first.json second.json latest.json --json',
299
- boundary: 'The command is offline, accepts 2 to 20 bounded inputs for one domain, retains no filenames or raw registry payloads, and does not treat changed collection conditions as a domain change.',
300
- },
301
- export: {
302
- description: 'Convert one saved lookup into a versioned evidence report.',
303
- example: 'whoisleuth export lookup.json --markdown',
304
- boundary: 'Exports preserve source attribution and limitations. Compact output intentionally omits raw registry payloads.',
305
- },
306
- });
307
- const COMMAND_COLLECTION = Object.freeze({
308
- completion: { mode: 'offline', scope: 'Prints one static script and changes no shell configuration.' },
309
- doctor: { mode: 'network', scope: 'Network access is opt-in with --network and is limited to fixed public DNS, HTTPS, and WHOIS diagnostics.' },
310
- commands: { mode: 'offline', scope: 'Reads the embedded command catalogue and performs no collection.' },
311
- manual: { mode: 'offline', scope: 'Builds documentation from the embedded command catalogue.' },
312
- lookup: { mode: 'network', scope: 'Accepts one target. Fast is the default; deep collection must be selected explicitly.' },
313
- bulk: { mode: 'network', scope: 'Accepts at most 500 fast or 50 deep targets, with concurrency capped at 8 fast or 3 deep.' },
314
- 'ct-search': { mode: 'network', scope: 'Accepts one bounded search keyword and queries the fixed certificate-transparency source.' },
315
- discover: { mode: 'offline', scope: 'Generates a bounded candidate set from local rules, dictionaries, and optional saved snapshots.' },
316
- 'discover-scan': { mode: 'network', scope: 'Scans at most 500 fast or 50 deep candidates, with concurrency capped at 8 fast or 3 deep.' },
317
- posture: { mode: 'network', scope: 'Accepts one domain and performs bounded DNS queries only.' },
318
- http: { mode: 'network', scope: 'Accepts one domain and follows only the bounded SSRF-guarded homepage redirect workflow.' },
319
- tls: { mode: 'network', scope: 'Accepts one public hostname and opens one bounded certificate connection.' },
320
- 'registry-support': { mode: 'offline', scope: 'Reads the embedded registry capability catalogue for one domain or suffix.' },
321
- 'registry-doctor': { mode: 'offline', scope: 'Reads one saved Lookup and the embedded registry capability catalogue.' },
322
- 'risk-calibrate': { mode: 'offline', scope: 'Reads one bounded reviewed-label dataset and changes no model or evidence.' },
323
- 'lookalike-calibrate': { mode: 'offline', scope: 'Reads at most 5,000 reviewed candidate labels from one dataset capped at 2 MiB.' },
324
- 'verify-artifact': { mode: 'offline', scope: 'Reads one selected bounded archive, packet, manifest, or saved Lookup document.' },
325
- 'inspect-archive': { mode: 'offline', scope: 'Reads one selected bounded workspace archive with redacted output by default.' },
326
- 'sign-artifact': { mode: 'offline', scope: 'Reads one selected artefact and one local private key without transmitting either.' },
327
- 'verify-signature': { mode: 'offline', scope: 'Reads one selected signed package and optional local public key.' },
328
- 'source-report': { mode: 'offline', scope: 'Reads bounded saved evidence and emits target-free source reliability data.' },
329
- compare: { mode: 'offline', scope: 'Reads one saved Lookup and compares its separately attributed registry publications.' },
330
- 'page-compare': { mode: 'offline', scope: 'Reads two saved Lookup documents and executes no page code.' },
331
- 'mail-review': { mode: 'offline', scope: 'Reads one saved Bulk result and sends no DNS or SMTP traffic.' },
332
- 'review-evidence': { mode: 'offline', scope: 'Reads one bounded versioned evidence or request-planning document and performs no collection.' },
333
- 'domain-control': { mode: 'offline', scope: 'Reads one bounded desired-state or review document and performs no collection or configuration change.' },
334
- assurance: { mode: 'offline', scope: 'Reads one versioned plan capped at 2 MiB and makes no request or configuration change.' },
335
- 'sharing-review': { mode: 'offline', scope: 'Reads one artefact capped at 15 MiB, emits only bounded schema/version metadata and no content values, and performs no transmission.' },
336
- 'workflow-plan': { mode: 'offline', scope: 'Builds a fixed typed recipe and executes none of its network or file steps.' },
337
- diff: { mode: 'offline', scope: 'Reads two saved Lookup documents for different domains.' },
338
- reconcile: { mode: 'offline', scope: 'Reads 2 to 5 saved observations for one domain, capped at 32 MiB in total.' },
339
- timeline: { mode: 'offline', scope: 'Reads 2 to 20 saved observations for one domain, capped at 32 MiB in total.' },
340
- export: { mode: 'offline', scope: 'Reads one saved Lookup and writes one bounded report.' },
341
- });
342
- function commandHelp(command) {
343
- const detail = COMMAND_DETAILS[command];
344
- const collection = COMMAND_COLLECTION[command];
345
- return `WHOISleuth ${command}\n${detail.description}\n\nUsage:\n ${COMMAND_USAGE[command]}\n\nExample:\n ${detail.example}\n\nCollection:\n ${collection.mode === 'offline' ? 'Offline' : 'Network'}: ${collection.scope}\n\nBoundary:\n ${detail.boundary}\n\nRun "whoisleuth --help" to see the grouped command list.\n`;
346
- }
347
60
  async function readStdinBounded(stream, limit = MAX_STDIN_BYTES) {
348
61
  if (!stream || stream.isTTY)
349
62
  return '';
@@ -475,6 +188,84 @@ async function runParsedCli(args, dependencies = {}) {
475
188
  }));
476
189
  return EXIT_CODES.SUCCESS;
477
190
  }
191
+ if (args.action === 'manifest') {
192
+ failureLabel = 'Investigation manifest';
193
+ const artifacts = [];
194
+ try {
195
+ for (const source of args.sources) {
196
+ const content = dependencies.readDiffInput
197
+ ? await dependencies.readDiffInput(source)
198
+ : await readSavedLookupInputBounded(createReadStream(source, { highWaterMark: 64 * 1024 }), { limit: MAX_INVESTIGATION_MANIFEST_ARTIFACT_BYTES, label: 'Manifest artefact input' });
199
+ artifacts.push({ content });
200
+ }
201
+ }
202
+ catch (error) {
203
+ if (error instanceof CliUsageError)
204
+ throw error;
205
+ throw new CliUsageError(`Could not read manifest artefact input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
206
+ }
207
+ let document;
208
+ try {
209
+ document = await buildInvestigationManifest({
210
+ workflow: args.workflow,
211
+ configurationDigestSha256: args.configurationDigestSha256,
212
+ artifacts,
213
+ }, commandContext.now(), VERSION);
214
+ }
215
+ catch (error) {
216
+ throw new CliUsageError(boundedCliErrorMessage(error, 'Investigation manifest input is invalid'));
217
+ }
218
+ if (!args.quiet)
219
+ write(stdout, args.output === 'json'
220
+ ? formatJsonDocument(document)
221
+ : terminal(formatInvestigationManifest(document), args.color));
222
+ return EXIT_CODES.SUCCESS;
223
+ }
224
+ if (args.action === 'map-observations' || args.action === 'oam-export') {
225
+ const mapping = args.action === 'map-observations';
226
+ failureLabel = mapping ? 'External observation mapping' : 'Open Asset Model export';
227
+ let input;
228
+ try {
229
+ input = dependencies.readArtifactInput
230
+ ? await dependencies.readArtifactInput(args.source)
231
+ : await readSavedLookupInputBounded(args.source
232
+ ? createReadStream(args.source, { highWaterMark: 64 * 1024 })
233
+ : dependencies.stdin || process.stdin, {
234
+ limit: MAX_EXTERNAL_OBSERVATION_MAPPING_BYTES,
235
+ label: mapping ? 'External observation mapping input' : 'Open Asset Model bridge input',
236
+ });
237
+ }
238
+ catch (error) {
239
+ if (error instanceof CliUsageError)
240
+ throw error;
241
+ throw new CliUsageError(`Could not read ${mapping ? 'observation mapping' : 'asset bridge'} input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
242
+ }
243
+ if (!input.trim())
244
+ throw new CliUsageError(`${args.action} requires one versioned JSON file or a document on stdin.`);
245
+ let parsed;
246
+ try {
247
+ parsed = JSON.parse(input);
248
+ }
249
+ catch {
250
+ throw new CliUsageError(`${mapping ? 'External observation mapping' : 'Open Asset Model bridge'} input is not valid JSON.`);
251
+ }
252
+ let document;
253
+ try {
254
+ document = mapping
255
+ ? mapExternalObservations(parsed)
256
+ : buildOpenAssetModelBridge(parsed, commandContext.now());
257
+ }
258
+ catch (error) {
259
+ throw new CliUsageError(boundedCliErrorMessage(error, `${mapping ? 'External observation mapping' : 'Open Asset Model bridge'} input is invalid`));
260
+ }
261
+ if (!args.quiet)
262
+ write(stdout, args.output === 'json'
263
+ ? formatJsonDocument(document)
264
+ : terminal(mapping
265
+ ? formatExternalObservationMapping(document)
266
+ : formatOpenAssetModelBridge(document), args.color));
267
+ return EXIT_CODES.SUCCESS;
268
+ }
478
269
  if (args.action === 'doctor') {
479
270
  failureLabel = 'CLI diagnostics';
480
271
  const buildReport = () => buildDoctorReport({
@@ -540,6 +331,43 @@ async function runParsedCli(args, dependencies = {}) {
540
331
  : terminal(formatRegistryDoctorReport(report), args.color));
541
332
  return report.summary.investigate ? EXIT_CODES.PARTIAL_FAILURE : EXIT_CODES.SUCCESS;
542
333
  }
334
+ if (args.action === 'registry-cohort') {
335
+ failureLabel = 'Registry quality cohort';
336
+ let input;
337
+ try {
338
+ input = dependencies.readCompareInput
339
+ ? await dependencies.readCompareInput(args.source)
340
+ : await readSavedLookupInputBounded(args.source
341
+ ? createReadStream(args.source, { highWaterMark: 64 * 1024 })
342
+ : dependencies.stdin || process.stdin, {
343
+ limit: MAX_REGISTRY_COHORT_INPUT_BYTES,
344
+ label: 'Registry cohort input',
345
+ });
346
+ }
347
+ catch (error) {
348
+ if (error instanceof CliUsageError)
349
+ throw error;
350
+ throw new CliUsageError(`Could not read registry cohort input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
351
+ }
352
+ const report = buildRegistryCohortReport(input, commandContext.now());
353
+ if (!args.quiet)
354
+ write(stdout, args.output === 'json'
355
+ ? formatJsonDocument(report)
356
+ : terminal(formatRegistryCohortReport(report), args.color));
357
+ return report.cohorts.some((cohort) => cohort.state === 'review')
358
+ ? EXIT_CODES.PARTIAL_FAILURE
359
+ : EXIT_CODES.SUCCESS;
360
+ }
361
+ if (args.action === 'registry-scaffold') {
362
+ failureLabel = 'Registry fixture scaffold';
363
+ try {
364
+ write(stdout, buildRegistryFixtureScaffold(args.profile, args.suffix, args.scenario));
365
+ }
366
+ catch (error) {
367
+ throw new CliUsageError(boundedCliErrorMessage(error, 'Registry fixture scaffold failed'));
368
+ }
369
+ return EXIT_CODES.SUCCESS;
370
+ }
543
371
  if (args.action === 'risk-calibrate') {
544
372
  failureLabel = 'Risk calibration';
545
373
  let input;
@@ -801,6 +629,56 @@ async function runParsedCli(args, dependencies = {}) {
801
629
  write(stdout, args.output === 'json'
802
630
  ? formatJsonDocument(document)
803
631
  : terminal(formatOfflineEvidenceReview(document), args.color));
632
+ if (args.strictExit) {
633
+ const result = document.result && typeof document.result === 'object' && !Array.isArray(document.result)
634
+ ? document.result
635
+ : {};
636
+ const gate = result.gate && typeof result.gate === 'object' && !Array.isArray(result.gate)
637
+ ? result.gate
638
+ : null;
639
+ const zoneMismatch = document.kind === 'zone_intent' && (result.complete !== true
640
+ || (result.counts && typeof result.counts === 'object' && !Array.isArray(result.counts)
641
+ && ['different', 'missing', 'unexpected', 'incomplete'].some((key) => Number(result.counts[key]) > 0)));
642
+ if (gate?.pass === false || zoneMismatch)
643
+ return EXIT_CODES.PARTIAL_FAILURE;
644
+ }
645
+ return EXIT_CODES.SUCCESS;
646
+ }
647
+ if (args.action === 'brief' || args.action === 'case-pack') {
648
+ const isBrief = args.action === 'brief';
649
+ failureLabel = isBrief ? 'Lookup brief' : 'Case pack';
650
+ let input;
651
+ try {
652
+ input = dependencies.readArtifactInput
653
+ ? await dependencies.readArtifactInput(args.source)
654
+ : await readSavedLookupInputBounded(args.source
655
+ ? createReadStream(args.source, { highWaterMark: 64 * 1024 })
656
+ : dependencies.stdin || process.stdin, {
657
+ limit: isBrief ? MAX_SAVED_LOOKUP_INPUT_BYTES : 4 * 1024 * 1024,
658
+ label: isBrief ? 'Lookup brief input' : 'Case-pack input',
659
+ });
660
+ }
661
+ catch (error) {
662
+ if (error instanceof CliUsageError)
663
+ throw error;
664
+ throw new CliUsageError(`Could not read ${isBrief ? 'Lookup brief' : 'case-pack'} input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
665
+ }
666
+ if (!input.trim())
667
+ throw new CliUsageError(`${args.action} requires one JSON file or a document on stdin.`);
668
+ if (args.action === 'brief') {
669
+ const document = buildCliLookupBrief(input, commandContext.now());
670
+ if (!args.quiet)
671
+ write(stdout, args.output === 'json'
672
+ ? formatJsonDocument(document)
673
+ : terminal(formatCliLookupBrief(document), args.color));
674
+ }
675
+ else {
676
+ const document = buildCliCasePack(input, { audience: args.audience, reviewed: args.reviewed }, commandContext.now());
677
+ if (!args.quiet)
678
+ write(stdout, args.output === 'json'
679
+ ? formatJsonDocument(document)
680
+ : terminal(formatCliCasePack(document), args.color));
681
+ }
804
682
  return EXIT_CODES.SUCCESS;
805
683
  }
806
684
  if (args.action === 'domain-control') {
@@ -837,16 +715,81 @@ async function runParsedCli(args, dependencies = {}) {
837
715
  ? buildDomainControlManifest(parsed, commandContext.now())
838
716
  : schema === DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA
839
717
  ? reviewDomainControlManifest(parsed, commandContext.now())
840
- : null;
718
+ : schema === CLI_DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA
719
+ ? buildCliDomainControlReview(input, commandContext.now())
720
+ : schema === DOMAIN_CONTROL_FLIGHT_RECORDER_INPUT_SCHEMA
721
+ ? buildDomainControlFlightRecorder(parsed, commandContext.now())
722
+ : null;
841
723
  if (!document) {
842
- throw new CliUsageError(`Domain control input must use ${DOMAIN_CONTROL_MANIFEST_INPUT_SCHEMA} or ${DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA}.`);
724
+ throw new CliUsageError(`Domain control input must use a supported manifest, review, saved-Lookup review, or flight-recorder schema.`);
843
725
  }
726
+ const terminalDocument = schema === CLI_DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA
727
+ ? formatCliDomainControlReview(document)
728
+ : schema === DOMAIN_CONTROL_FLIGHT_RECORDER_INPUT_SCHEMA
729
+ ? formatDomainControlFlightRecorder(document)
730
+ : formatDomainControlResult(document);
844
731
  if (!args.quiet)
845
732
  write(stdout, args.output === 'json'
846
733
  ? formatJsonDocument(document)
847
- : terminal(formatDomainControlResult(document), args.color));
734
+ : terminal(terminalDocument, args.color));
848
735
  return EXIT_CODES.SUCCESS;
849
736
  }
737
+ if (args.action === 'monitor-once') {
738
+ failureLabel = 'One-shot domain control review';
739
+ let manifestInput;
740
+ let previousInput = null;
741
+ try {
742
+ manifestInput = dependencies.readArtifactInput
743
+ ? await dependencies.readArtifactInput(args.source)
744
+ : await readSavedLookupInputBounded(args.source
745
+ ? createReadStream(args.source, { highWaterMark: 64 * 1024 })
746
+ : dependencies.stdin || process.stdin, {
747
+ limit: MAX_OFFLINE_EVIDENCE_INPUT_BYTES,
748
+ label: 'Domain-control manifest input',
749
+ });
750
+ if (args.previousSource) {
751
+ previousInput = dependencies.readDiffInput
752
+ ? await dependencies.readDiffInput(args.previousSource)
753
+ : await readSavedLookupInputBounded(createReadStream(args.previousSource, { highWaterMark: 64 * 1024 }), {
754
+ limit: MAX_OFFLINE_EVIDENCE_INPUT_BYTES,
755
+ label: 'Prior monitor snapshot',
756
+ });
757
+ }
758
+ }
759
+ catch (error) {
760
+ if (error instanceof CliUsageError)
761
+ throw error;
762
+ throw new CliUsageError(`Could not read monitor input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
763
+ }
764
+ if (!manifestInput.trim())
765
+ throw new CliUsageError('monitor-once requires one domain-control manifest file or a document on stdin.');
766
+ const executeLookup = dependencies.runUnifiedLookup || (await import("../lib/lookup.mjs")).runUnifiedLookup;
767
+ const progress = commandContext.beginProgress('Collecting bounded domain-control evidence');
768
+ let document;
769
+ try {
770
+ document = await runDomainControlMonitor(manifestInput, previousInput, {
771
+ executeLookup,
772
+ now: commandContext.now,
773
+ limit: args.limit,
774
+ concurrency: args.concurrency,
775
+ ...(dependencies.signal ? { signal: dependencies.signal } : {}),
776
+ onSettled: (completed, total) => progress.update(`Collected ${completed} of ${total} owned domains`),
777
+ });
778
+ }
779
+ finally {
780
+ commandContext.endProgress();
781
+ }
782
+ if (!args.quiet)
783
+ write(stdout, args.output === 'json'
784
+ ? formatJsonDocument(document)
785
+ : args.output === 'junit'
786
+ ? formatCliJunit(document)
787
+ : terminal(formatDomainControlMonitor(document), args.color));
788
+ const policyFindings = evaluateCliFailPolicies(document, args.failOn || []);
789
+ if (policyFindings.length)
790
+ write(stderr, formatFailPolicyNotice(policyFindings));
791
+ return document.collection.failed || policyFindings.length ? EXIT_CODES.PARTIAL_FAILURE : EXIT_CODES.SUCCESS;
792
+ }
850
793
  if (args.action === 'assurance') {
851
794
  failureLabel = 'Domain assurance review';
852
795
  let input;
@@ -887,6 +830,46 @@ async function runParsedCli(args, dependencies = {}) {
887
830
  : terminal(formatDomainAssurance(document), args.color));
888
831
  return EXIT_CODES.SUCCESS;
889
832
  }
833
+ if (args.action === 'change-packet') {
834
+ failureLabel = 'Domain change packet';
835
+ let input;
836
+ try {
837
+ input = dependencies.readArtifactInput
838
+ ? await dependencies.readArtifactInput(args.source)
839
+ : await readSavedLookupInputBounded(args.source
840
+ ? createReadStream(args.source, { highWaterMark: 64 * 1024 })
841
+ : dependencies.stdin || process.stdin, {
842
+ limit: MAX_DOMAIN_CHANGE_PACKET_INPUT_BYTES,
843
+ label: 'Domain change packet input',
844
+ });
845
+ }
846
+ catch (error) {
847
+ if (error instanceof CliUsageError)
848
+ throw error;
849
+ throw new CliUsageError(`Could not read domain change packet input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
850
+ }
851
+ if (!input.trim())
852
+ throw new CliUsageError('change-packet requires one versioned JSON file or a document on stdin.');
853
+ let parsed;
854
+ try {
855
+ parsed = JSON.parse(input);
856
+ }
857
+ catch {
858
+ throw new CliUsageError('Domain change packet input is not valid JSON.');
859
+ }
860
+ let document;
861
+ try {
862
+ document = await buildDomainChangePacket(parsed, commandContext.now());
863
+ }
864
+ catch (error) {
865
+ throw new CliUsageError(boundedCliErrorMessage(error, 'Domain change packet input is invalid'));
866
+ }
867
+ if (!args.quiet)
868
+ write(stdout, args.output === 'json'
869
+ ? formatJsonDocument(document)
870
+ : terminal(formatDomainChangePacket(document), args.color));
871
+ return document.gate.pass ? EXIT_CODES.SUCCESS : EXIT_CODES.PARTIAL_FAILURE;
872
+ }
890
873
  if (args.action === 'sharing-review') {
891
874
  failureLabel = 'Evidence sharing review';
892
875
  let input;
@@ -936,6 +919,45 @@ async function runParsedCli(args, dependencies = {}) {
936
919
  : terminal(formatInvestigationPlan(document), args.color));
937
920
  return EXIT_CODES.SUCCESS;
938
921
  }
922
+ if (args.action === 'workflow-run') {
923
+ failureLabel = 'Investigation workflow';
924
+ let resumeInput = null;
925
+ if (args.resumeSource) {
926
+ try {
927
+ resumeInput = dependencies.readDiffInput
928
+ ? await dependencies.readDiffInput(args.resumeSource)
929
+ : await readSavedLookupInputBounded(createReadStream(args.resumeSource, { highWaterMark: 64 * 1024 }), {
930
+ limit: 24 * 1024 * 1024,
931
+ label: 'Investigation resume state',
932
+ });
933
+ }
934
+ catch (error) {
935
+ if (error instanceof CliUsageError)
936
+ throw error;
937
+ throw new CliUsageError(`Could not read investigation resume state: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
938
+ }
939
+ }
940
+ const document = await runInvestigationRecipe(args.recipe, args.subject, {
941
+ approveNetwork: args.approveNetwork,
942
+ resumeInput,
943
+ generatedAt: commandContext.now(),
944
+ execute: async (command, stepArguments) => {
945
+ const stepStdout = createBufferedOutput();
946
+ const stepStderr = createBufferedOutput();
947
+ const exitCode = await runCli([command, ...stepArguments], {
948
+ ...dependencies,
949
+ stdout: stepStdout.stream,
950
+ stderr: stepStderr.stream,
951
+ });
952
+ return { exitCode, stdout: stepStdout.value() };
953
+ },
954
+ });
955
+ if (!args.quiet)
956
+ write(stdout, args.output === 'json'
957
+ ? formatJsonDocument(document)
958
+ : terminal(formatInvestigationRun(document), args.color));
959
+ return document.state === 'step_failed' ? EXIT_CODES.PARTIAL_FAILURE : EXIT_CODES.SUCCESS;
960
+ }
939
961
  if (args.action === 'diff') {
940
962
  failureLabel = 'Lookup evidence diff';
941
963
  const readDiffInput = dependencies.readDiffInput || (async (source) => (readSavedLookupInputBounded(createReadStream(source, { highWaterMark: 64 * 1024 }), {
@@ -1069,6 +1091,46 @@ async function runParsedCli(args, dependencies = {}) {
1069
1091
  const { runDiscoveryScanCommand } = await import("./discovery-scan-command-runner.mjs");
1070
1092
  return await runDiscoveryScanCommand(args, dependencies, commandContext);
1071
1093
  }
1094
+ if (args.action === 'ct-intake') {
1095
+ failureLabel = 'Certificate event intake';
1096
+ let input;
1097
+ try {
1098
+ input = dependencies.readArtifactInput
1099
+ ? await dependencies.readArtifactInput(args.source)
1100
+ : await readSavedLookupInputBounded(args.source
1101
+ ? createReadStream(args.source, { highWaterMark: 64 * 1024 })
1102
+ : dependencies.stdin || process.stdin, {
1103
+ limit: MAX_CT_EVENT_INPUT_BYTES,
1104
+ label: 'Certificate event input',
1105
+ });
1106
+ }
1107
+ catch (error) {
1108
+ if (error instanceof CliUsageError)
1109
+ throw error;
1110
+ throw new CliUsageError(`Could not read certificate event input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
1111
+ }
1112
+ if (!input.trim())
1113
+ throw new CliUsageError('ct-intake requires one versioned JSON file or a document on stdin.');
1114
+ let parsed;
1115
+ try {
1116
+ parsed = JSON.parse(input);
1117
+ }
1118
+ catch {
1119
+ throw new CliUsageError('Certificate event input is not valid JSON.');
1120
+ }
1121
+ let document;
1122
+ try {
1123
+ document = buildCtEventFindings(parsed);
1124
+ }
1125
+ catch (error) {
1126
+ throw new CliUsageError(boundedCliErrorMessage(error, 'Certificate event input is invalid'));
1127
+ }
1128
+ if (!args.quiet)
1129
+ write(stdout, args.output === 'json'
1130
+ ? formatJsonDocument(document)
1131
+ : terminal(formatCtEventFindings(document), args.color));
1132
+ return EXIT_CODES.SUCCESS;
1133
+ }
1072
1134
  if (args.action === 'ct-search'
1073
1135
  || args.action === 'posture'
1074
1136
  || args.action === 'http'