@slicedearth/whoisleuth-cli 1.39.1 → 1.45.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/README.md +23 -4
- package/bin/whoisleuth.mjs +31 -9
- package/cli/archive-inspect.mjs +37 -2
- package/cli/arguments.mjs +361 -256
- package/cli/artifact-verify.mjs +35 -1
- package/cli/bulk-checkpoint.mjs +72 -39
- package/cli/bulk-command-runner.mjs +34 -4
- package/cli/bulk.mjs +18 -7
- package/cli/case-pack.mjs +136 -0
- package/cli/ci-report.mjs +73 -0
- package/cli/collection-preflight.mjs +59 -0
- package/cli/command-reference.mjs +395 -0
- package/cli/completion.mjs +67 -13
- package/cli/config-profile.mjs +183 -0
- package/cli/ct-event-intake.mjs +159 -0
- package/cli/discovery-observation-snapshot.mjs +8 -14
- package/cli/discovery-scan-command-runner.mjs +29 -2
- package/cli/discovery-snapshot.mjs +8 -15
- package/cli/domain-control-monitor.mjs +104 -0
- package/cli/domain-control-observations.mjs +235 -0
- package/cli/errors.mjs +7 -1
- package/cli/evidence-command-arguments.mjs +11 -0
- package/cli/evidence-command-runner.mjs +1 -0
- package/cli/external-observation-mapping.mjs +162 -0
- package/cli/fail-policy.mjs +64 -0
- package/cli/formatters/html.mjs +1 -1
- package/cli/formatters/json.mjs +12 -4
- package/cli/formatters/terminal.mjs +1 -1
- package/cli/http.mjs +2 -1
- package/cli/investigation-manifest.mjs +113 -0
- package/cli/investigation-run.mjs +112 -0
- package/cli/lookup-brief.mjs +116 -0
- package/cli/lookup-command-runner.mjs +8 -1
- package/cli/lookup-diff.mjs +17 -19
- package/cli/lookup-reconcile.mjs +1 -1
- package/cli/mail-review.mjs +5 -5
- package/cli/manual.mjs +1 -1
- package/cli/network-command-runner.mjs +4 -1
- package/cli/offline-evidence-review.mjs +105 -8
- package/cli/open-asset-model-bridge.mjs +169 -0
- package/cli/registry-cohort.mjs +121 -0
- package/cli/registry-doctor.mjs +106 -11
- package/cli/registry-fixture-scaffold.mjs +74 -0
- package/cli/runner.mjs +388 -315
- package/docs/cli-reference.md +266 -21
- package/docs/cli.md +43 -7
- package/frontend/src/lib/analysis/acquisition-due-diligence.js +2 -2
- package/frontend/src/lib/analysis/brand-profile-model.js +50 -6
- package/frontend/src/lib/analysis/case-evidence-model.js +1 -1
- package/frontend/src/lib/analysis/case-record-core.js +1 -1
- package/frontend/src/lib/analysis/case-record-operations.js +1 -1
- package/frontend/src/lib/analysis/case-report.js +573 -0
- package/frontend/src/lib/analysis/case-response-model.js +30 -1
- package/frontend/src/lib/analysis/detection-rule-model.js +36 -0
- package/frontend/src/lib/analysis/external-findings-import.js +320 -0
- package/frontend/src/lib/analysis/lookup-asset-graph.js +8 -8
- package/frontend/src/lib/analysis/lookup-decision-support.js +9 -2
- package/frontend/src/lib/analysis/lookup-presentation.js +14 -30
- package/frontend/src/lib/analysis/lookup-source-refresh.js +36 -63
- package/frontend/src/lib/analysis/scoring.js +1 -1
- package/frontend/src/lib/analysis/utils.js +1 -1
- package/frontend/src/lib/analysis/visualization-models.js +2 -3
- package/frontend/src/lib/analysis/workspace-archive-crypto.js +1 -4
- package/frontend/src/lib/analysis/workspace-archive.js +5 -7
- package/lib/abusech-auth.mjs +1 -1
- package/lib/availability.mjs +1 -1
- package/lib/bounded-contract-normalizers.mjs +33 -0
- package/lib/bounded-file.mjs +69 -0
- package/lib/bounded-json-response.mjs +157 -0
- package/lib/browser-library-profile.mjs +167 -38
- package/lib/dns-convergence-review.mjs +183 -0
- package/lib/dns-delegation-health.mjs +196 -3
- package/lib/domain-change-packet.mjs +133 -0
- package/lib/domain-change-review.mjs +307 -0
- package/lib/domain-control-flight-recorder.mjs +268 -0
- package/lib/domain-portfolio-review.mjs +151 -0
- package/lib/evidence-export.mjs +1 -1
- package/lib/html-signals.mjs +5 -11
- package/lib/lookup-cache.mjs +5 -1
- package/lib/nameserver-preflight-review.mjs +159 -0
- package/lib/page-language-signals.mjs +124 -0
- package/lib/rdap-transport.mjs +6 -6
- package/lib/risk-scoring.mjs +42 -1
- package/lib/safe-fetch.mjs +37 -32
- package/lib/static-html-analysis.mjs +29 -1
- package/lib/threat-intelligence-runtime.mjs +1 -2
- package/lib/trust-store-comparison.mjs +146 -0
- package/lib/website-technology.mjs +22 -12
- package/lib/zone-intent-review.mjs +534 -0
- 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 {
|
|
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,319 +57,28 @@ 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
|
-
|
|
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
|
-
async function readStdinBounded(stream, limit = MAX_STDIN_BYTES) {
|
|
60
|
+
async function readStdinBounded(stream, limit = MAX_STDIN_BYTES, signal) {
|
|
348
61
|
if (!stream || stream.isTTY)
|
|
349
62
|
return '';
|
|
63
|
+
const abort = () => stream.destroy?.(new DOMException('Aborted', 'AbortError'));
|
|
64
|
+
if (signal?.aborted)
|
|
65
|
+
throw new DOMException('Aborted', 'AbortError');
|
|
66
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
350
67
|
const chunks = [];
|
|
351
68
|
let total = 0;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
69
|
+
try {
|
|
70
|
+
for await (const chunk of stream) {
|
|
71
|
+
if (signal?.aborted)
|
|
72
|
+
throw new DOMException('Aborted', 'AbortError');
|
|
73
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
74
|
+
total += buffer.length;
|
|
75
|
+
if (total > limit)
|
|
76
|
+
throw new CliUsageError(`Standard input is limited to ${limit} bytes.`);
|
|
77
|
+
chunks.push(buffer);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
signal?.removeEventListener('abort', abort);
|
|
358
82
|
}
|
|
359
83
|
const text = Buffer.concat(chunks).toString('utf8').trim();
|
|
360
84
|
const lines = text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
@@ -423,7 +147,7 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
423
147
|
};
|
|
424
148
|
const readSingleInput = async () => (dependencies.readStdin
|
|
425
149
|
? await dependencies.readStdin()
|
|
426
|
-
: await readStdinBounded(dependencies.stdin || process.stdin));
|
|
150
|
+
: await readStdinBounded(dependencies.stdin || process.stdin, MAX_STDIN_BYTES, dependencies.signal));
|
|
427
151
|
const commandContext = Object.freeze({
|
|
428
152
|
stdout,
|
|
429
153
|
stderr,
|
|
@@ -475,6 +199,84 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
475
199
|
}));
|
|
476
200
|
return EXIT_CODES.SUCCESS;
|
|
477
201
|
}
|
|
202
|
+
if (args.action === 'manifest') {
|
|
203
|
+
failureLabel = 'Investigation manifest';
|
|
204
|
+
const artifacts = [];
|
|
205
|
+
try {
|
|
206
|
+
for (const source of args.sources) {
|
|
207
|
+
const content = dependencies.readDiffInput
|
|
208
|
+
? await dependencies.readDiffInput(source)
|
|
209
|
+
: await readSavedLookupInputBounded(createReadStream(source, { highWaterMark: 64 * 1024 }), { limit: MAX_INVESTIGATION_MANIFEST_ARTIFACT_BYTES, label: 'Manifest artefact input' });
|
|
210
|
+
artifacts.push({ content });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
if (error instanceof CliUsageError)
|
|
215
|
+
throw error;
|
|
216
|
+
throw new CliUsageError(`Could not read manifest artefact input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
217
|
+
}
|
|
218
|
+
let document;
|
|
219
|
+
try {
|
|
220
|
+
document = await buildInvestigationManifest({
|
|
221
|
+
workflow: args.workflow,
|
|
222
|
+
configurationDigestSha256: args.configurationDigestSha256,
|
|
223
|
+
artifacts,
|
|
224
|
+
}, commandContext.now(), VERSION);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
throw new CliUsageError(boundedCliErrorMessage(error, 'Investigation manifest input is invalid'));
|
|
228
|
+
}
|
|
229
|
+
if (!args.quiet)
|
|
230
|
+
write(stdout, args.output === 'json'
|
|
231
|
+
? formatJsonDocument(document)
|
|
232
|
+
: terminal(formatInvestigationManifest(document), args.color));
|
|
233
|
+
return EXIT_CODES.SUCCESS;
|
|
234
|
+
}
|
|
235
|
+
if (args.action === 'map-observations' || args.action === 'oam-export') {
|
|
236
|
+
const mapping = args.action === 'map-observations';
|
|
237
|
+
failureLabel = mapping ? 'External observation mapping' : 'Open Asset Model export';
|
|
238
|
+
let input;
|
|
239
|
+
try {
|
|
240
|
+
input = dependencies.readArtifactInput
|
|
241
|
+
? await dependencies.readArtifactInput(args.source)
|
|
242
|
+
: await readSavedLookupInputBounded(args.source
|
|
243
|
+
? createReadStream(args.source, { highWaterMark: 64 * 1024 })
|
|
244
|
+
: dependencies.stdin || process.stdin, {
|
|
245
|
+
limit: MAX_EXTERNAL_OBSERVATION_MAPPING_BYTES,
|
|
246
|
+
label: mapping ? 'External observation mapping input' : 'Open Asset Model bridge input',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
if (error instanceof CliUsageError)
|
|
251
|
+
throw error;
|
|
252
|
+
throw new CliUsageError(`Could not read ${mapping ? 'observation mapping' : 'asset bridge'} input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
253
|
+
}
|
|
254
|
+
if (!input.trim())
|
|
255
|
+
throw new CliUsageError(`${args.action} requires one versioned JSON file or a document on stdin.`);
|
|
256
|
+
let parsed;
|
|
257
|
+
try {
|
|
258
|
+
parsed = JSON.parse(input);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
throw new CliUsageError(`${mapping ? 'External observation mapping' : 'Open Asset Model bridge'} input is not valid JSON.`);
|
|
262
|
+
}
|
|
263
|
+
let document;
|
|
264
|
+
try {
|
|
265
|
+
document = mapping
|
|
266
|
+
? mapExternalObservations(parsed)
|
|
267
|
+
: buildOpenAssetModelBridge(parsed, commandContext.now());
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
throw new CliUsageError(boundedCliErrorMessage(error, `${mapping ? 'External observation mapping' : 'Open Asset Model bridge'} input is invalid`));
|
|
271
|
+
}
|
|
272
|
+
if (!args.quiet)
|
|
273
|
+
write(stdout, args.output === 'json'
|
|
274
|
+
? formatJsonDocument(document)
|
|
275
|
+
: terminal(mapping
|
|
276
|
+
? formatExternalObservationMapping(document)
|
|
277
|
+
: formatOpenAssetModelBridge(document), args.color));
|
|
278
|
+
return EXIT_CODES.SUCCESS;
|
|
279
|
+
}
|
|
478
280
|
if (args.action === 'doctor') {
|
|
479
281
|
failureLabel = 'CLI diagnostics';
|
|
480
282
|
const buildReport = () => buildDoctorReport({
|
|
@@ -498,7 +300,7 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
498
300
|
}
|
|
499
301
|
if (args.action === 'registry-support') {
|
|
500
302
|
failureLabel = 'Registry support';
|
|
501
|
-
const readInput = dependencies.readStdin || (() => readStdinBounded(dependencies.stdin || process.stdin));
|
|
303
|
+
const readInput = dependencies.readStdin || (() => readStdinBounded(dependencies.stdin || process.stdin, MAX_STDIN_BYTES, dependencies.signal));
|
|
502
304
|
const requestedInput = args.target || await readInput();
|
|
503
305
|
if (!requestedInput)
|
|
504
306
|
throw new CliUsageError('registry-support requires one domain or suffix as an argument or on stdin.');
|
|
@@ -540,6 +342,43 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
540
342
|
: terminal(formatRegistryDoctorReport(report), args.color));
|
|
541
343
|
return report.summary.investigate ? EXIT_CODES.PARTIAL_FAILURE : EXIT_CODES.SUCCESS;
|
|
542
344
|
}
|
|
345
|
+
if (args.action === 'registry-cohort') {
|
|
346
|
+
failureLabel = 'Registry quality cohort';
|
|
347
|
+
let input;
|
|
348
|
+
try {
|
|
349
|
+
input = dependencies.readCompareInput
|
|
350
|
+
? await dependencies.readCompareInput(args.source)
|
|
351
|
+
: await readSavedLookupInputBounded(args.source
|
|
352
|
+
? createReadStream(args.source, { highWaterMark: 64 * 1024 })
|
|
353
|
+
: dependencies.stdin || process.stdin, {
|
|
354
|
+
limit: MAX_REGISTRY_COHORT_INPUT_BYTES,
|
|
355
|
+
label: 'Registry cohort input',
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
if (error instanceof CliUsageError)
|
|
360
|
+
throw error;
|
|
361
|
+
throw new CliUsageError(`Could not read registry cohort input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
362
|
+
}
|
|
363
|
+
const report = buildRegistryCohortReport(input, commandContext.now());
|
|
364
|
+
if (!args.quiet)
|
|
365
|
+
write(stdout, args.output === 'json'
|
|
366
|
+
? formatJsonDocument(report)
|
|
367
|
+
: terminal(formatRegistryCohortReport(report), args.color));
|
|
368
|
+
return report.cohorts.some((cohort) => cohort.state === 'review')
|
|
369
|
+
? EXIT_CODES.PARTIAL_FAILURE
|
|
370
|
+
: EXIT_CODES.SUCCESS;
|
|
371
|
+
}
|
|
372
|
+
if (args.action === 'registry-scaffold') {
|
|
373
|
+
failureLabel = 'Registry fixture scaffold';
|
|
374
|
+
try {
|
|
375
|
+
write(stdout, buildRegistryFixtureScaffold(args.profile, args.suffix, args.scenario));
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
throw new CliUsageError(boundedCliErrorMessage(error, 'Registry fixture scaffold failed'));
|
|
379
|
+
}
|
|
380
|
+
return EXIT_CODES.SUCCESS;
|
|
381
|
+
}
|
|
543
382
|
if (args.action === 'risk-calibrate') {
|
|
544
383
|
failureLabel = 'Risk calibration';
|
|
545
384
|
let input;
|
|
@@ -801,6 +640,56 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
801
640
|
write(stdout, args.output === 'json'
|
|
802
641
|
? formatJsonDocument(document)
|
|
803
642
|
: terminal(formatOfflineEvidenceReview(document), args.color));
|
|
643
|
+
if (args.strictExit) {
|
|
644
|
+
const result = document.result && typeof document.result === 'object' && !Array.isArray(document.result)
|
|
645
|
+
? document.result
|
|
646
|
+
: {};
|
|
647
|
+
const gate = result.gate && typeof result.gate === 'object' && !Array.isArray(result.gate)
|
|
648
|
+
? result.gate
|
|
649
|
+
: null;
|
|
650
|
+
const zoneMismatch = document.kind === 'zone_intent' && (result.complete !== true
|
|
651
|
+
|| (result.counts && typeof result.counts === 'object' && !Array.isArray(result.counts)
|
|
652
|
+
&& ['different', 'missing', 'unexpected', 'incomplete'].some((key) => Number(result.counts[key]) > 0)));
|
|
653
|
+
if (gate?.pass === false || zoneMismatch)
|
|
654
|
+
return EXIT_CODES.PARTIAL_FAILURE;
|
|
655
|
+
}
|
|
656
|
+
return EXIT_CODES.SUCCESS;
|
|
657
|
+
}
|
|
658
|
+
if (args.action === 'brief' || args.action === 'case-pack') {
|
|
659
|
+
const isBrief = args.action === 'brief';
|
|
660
|
+
failureLabel = isBrief ? 'Lookup brief' : 'Case pack';
|
|
661
|
+
let input;
|
|
662
|
+
try {
|
|
663
|
+
input = dependencies.readArtifactInput
|
|
664
|
+
? await dependencies.readArtifactInput(args.source)
|
|
665
|
+
: await readSavedLookupInputBounded(args.source
|
|
666
|
+
? createReadStream(args.source, { highWaterMark: 64 * 1024 })
|
|
667
|
+
: dependencies.stdin || process.stdin, {
|
|
668
|
+
limit: isBrief ? MAX_SAVED_LOOKUP_INPUT_BYTES : 4 * 1024 * 1024,
|
|
669
|
+
label: isBrief ? 'Lookup brief input' : 'Case-pack input',
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
if (error instanceof CliUsageError)
|
|
674
|
+
throw error;
|
|
675
|
+
throw new CliUsageError(`Could not read ${isBrief ? 'Lookup brief' : 'case-pack'} input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
676
|
+
}
|
|
677
|
+
if (!input.trim())
|
|
678
|
+
throw new CliUsageError(`${args.action} requires one JSON file or a document on stdin.`);
|
|
679
|
+
if (args.action === 'brief') {
|
|
680
|
+
const document = buildCliLookupBrief(input, commandContext.now());
|
|
681
|
+
if (!args.quiet)
|
|
682
|
+
write(stdout, args.output === 'json'
|
|
683
|
+
? formatJsonDocument(document)
|
|
684
|
+
: terminal(formatCliLookupBrief(document), args.color));
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
const document = buildCliCasePack(input, { audience: args.audience, reviewed: args.reviewed }, commandContext.now());
|
|
688
|
+
if (!args.quiet)
|
|
689
|
+
write(stdout, args.output === 'json'
|
|
690
|
+
? formatJsonDocument(document)
|
|
691
|
+
: terminal(formatCliCasePack(document), args.color));
|
|
692
|
+
}
|
|
804
693
|
return EXIT_CODES.SUCCESS;
|
|
805
694
|
}
|
|
806
695
|
if (args.action === 'domain-control') {
|
|
@@ -837,16 +726,81 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
837
726
|
? buildDomainControlManifest(parsed, commandContext.now())
|
|
838
727
|
: schema === DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA
|
|
839
728
|
? reviewDomainControlManifest(parsed, commandContext.now())
|
|
840
|
-
:
|
|
729
|
+
: schema === CLI_DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA
|
|
730
|
+
? buildCliDomainControlReview(input, commandContext.now())
|
|
731
|
+
: schema === DOMAIN_CONTROL_FLIGHT_RECORDER_INPUT_SCHEMA
|
|
732
|
+
? buildDomainControlFlightRecorder(parsed, commandContext.now())
|
|
733
|
+
: null;
|
|
841
734
|
if (!document) {
|
|
842
|
-
throw new CliUsageError(`Domain control input must use
|
|
735
|
+
throw new CliUsageError(`Domain control input must use a supported manifest, review, saved-Lookup review, or flight-recorder schema.`);
|
|
843
736
|
}
|
|
737
|
+
const terminalDocument = schema === CLI_DOMAIN_CONTROL_REVIEW_INPUT_SCHEMA
|
|
738
|
+
? formatCliDomainControlReview(document)
|
|
739
|
+
: schema === DOMAIN_CONTROL_FLIGHT_RECORDER_INPUT_SCHEMA
|
|
740
|
+
? formatDomainControlFlightRecorder(document)
|
|
741
|
+
: formatDomainControlResult(document);
|
|
844
742
|
if (!args.quiet)
|
|
845
743
|
write(stdout, args.output === 'json'
|
|
846
744
|
? formatJsonDocument(document)
|
|
847
|
-
: terminal(
|
|
745
|
+
: terminal(terminalDocument, args.color));
|
|
848
746
|
return EXIT_CODES.SUCCESS;
|
|
849
747
|
}
|
|
748
|
+
if (args.action === 'monitor-once') {
|
|
749
|
+
failureLabel = 'One-shot domain control review';
|
|
750
|
+
let manifestInput;
|
|
751
|
+
let previousInput = null;
|
|
752
|
+
try {
|
|
753
|
+
manifestInput = dependencies.readArtifactInput
|
|
754
|
+
? await dependencies.readArtifactInput(args.source)
|
|
755
|
+
: await readSavedLookupInputBounded(args.source
|
|
756
|
+
? createReadStream(args.source, { highWaterMark: 64 * 1024 })
|
|
757
|
+
: dependencies.stdin || process.stdin, {
|
|
758
|
+
limit: MAX_OFFLINE_EVIDENCE_INPUT_BYTES,
|
|
759
|
+
label: 'Domain-control manifest input',
|
|
760
|
+
});
|
|
761
|
+
if (args.previousSource) {
|
|
762
|
+
previousInput = dependencies.readDiffInput
|
|
763
|
+
? await dependencies.readDiffInput(args.previousSource)
|
|
764
|
+
: await readSavedLookupInputBounded(createReadStream(args.previousSource, { highWaterMark: 64 * 1024 }), {
|
|
765
|
+
limit: MAX_OFFLINE_EVIDENCE_INPUT_BYTES,
|
|
766
|
+
label: 'Prior monitor snapshot',
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
catch (error) {
|
|
771
|
+
if (error instanceof CliUsageError)
|
|
772
|
+
throw error;
|
|
773
|
+
throw new CliUsageError(`Could not read monitor input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
774
|
+
}
|
|
775
|
+
if (!manifestInput.trim())
|
|
776
|
+
throw new CliUsageError('monitor-once requires one domain-control manifest file or a document on stdin.');
|
|
777
|
+
const executeLookup = dependencies.runUnifiedLookup || (await import("../lib/lookup.mjs")).runUnifiedLookup;
|
|
778
|
+
const progress = commandContext.beginProgress('Collecting bounded domain-control evidence');
|
|
779
|
+
let document;
|
|
780
|
+
try {
|
|
781
|
+
document = await runDomainControlMonitor(manifestInput, previousInput, {
|
|
782
|
+
executeLookup,
|
|
783
|
+
now: commandContext.now,
|
|
784
|
+
limit: args.limit,
|
|
785
|
+
concurrency: args.concurrency,
|
|
786
|
+
...(dependencies.signal ? { signal: dependencies.signal } : {}),
|
|
787
|
+
onSettled: (completed, total) => progress.update(`Collected ${completed} of ${total} owned domains`),
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
finally {
|
|
791
|
+
commandContext.endProgress();
|
|
792
|
+
}
|
|
793
|
+
if (!args.quiet)
|
|
794
|
+
write(stdout, args.output === 'json'
|
|
795
|
+
? formatJsonDocument(document)
|
|
796
|
+
: args.output === 'junit'
|
|
797
|
+
? formatCliJunit(document)
|
|
798
|
+
: terminal(formatDomainControlMonitor(document), args.color));
|
|
799
|
+
const policyFindings = evaluateCliFailPolicies(document, args.failOn || []);
|
|
800
|
+
if (policyFindings.length)
|
|
801
|
+
write(stderr, formatFailPolicyNotice(policyFindings));
|
|
802
|
+
return document.collection.failed || policyFindings.length ? EXIT_CODES.PARTIAL_FAILURE : EXIT_CODES.SUCCESS;
|
|
803
|
+
}
|
|
850
804
|
if (args.action === 'assurance') {
|
|
851
805
|
failureLabel = 'Domain assurance review';
|
|
852
806
|
let input;
|
|
@@ -887,6 +841,46 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
887
841
|
: terminal(formatDomainAssurance(document), args.color));
|
|
888
842
|
return EXIT_CODES.SUCCESS;
|
|
889
843
|
}
|
|
844
|
+
if (args.action === 'change-packet') {
|
|
845
|
+
failureLabel = 'Domain change packet';
|
|
846
|
+
let input;
|
|
847
|
+
try {
|
|
848
|
+
input = dependencies.readArtifactInput
|
|
849
|
+
? await dependencies.readArtifactInput(args.source)
|
|
850
|
+
: await readSavedLookupInputBounded(args.source
|
|
851
|
+
? createReadStream(args.source, { highWaterMark: 64 * 1024 })
|
|
852
|
+
: dependencies.stdin || process.stdin, {
|
|
853
|
+
limit: MAX_DOMAIN_CHANGE_PACKET_INPUT_BYTES,
|
|
854
|
+
label: 'Domain change packet input',
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
catch (error) {
|
|
858
|
+
if (error instanceof CliUsageError)
|
|
859
|
+
throw error;
|
|
860
|
+
throw new CliUsageError(`Could not read domain change packet input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
861
|
+
}
|
|
862
|
+
if (!input.trim())
|
|
863
|
+
throw new CliUsageError('change-packet requires one versioned JSON file or a document on stdin.');
|
|
864
|
+
let parsed;
|
|
865
|
+
try {
|
|
866
|
+
parsed = JSON.parse(input);
|
|
867
|
+
}
|
|
868
|
+
catch {
|
|
869
|
+
throw new CliUsageError('Domain change packet input is not valid JSON.');
|
|
870
|
+
}
|
|
871
|
+
let document;
|
|
872
|
+
try {
|
|
873
|
+
document = await buildDomainChangePacket(parsed, commandContext.now());
|
|
874
|
+
}
|
|
875
|
+
catch (error) {
|
|
876
|
+
throw new CliUsageError(boundedCliErrorMessage(error, 'Domain change packet input is invalid'));
|
|
877
|
+
}
|
|
878
|
+
if (!args.quiet)
|
|
879
|
+
write(stdout, args.output === 'json'
|
|
880
|
+
? formatJsonDocument(document)
|
|
881
|
+
: terminal(formatDomainChangePacket(document), args.color));
|
|
882
|
+
return document.gate.pass ? EXIT_CODES.SUCCESS : EXIT_CODES.PARTIAL_FAILURE;
|
|
883
|
+
}
|
|
890
884
|
if (args.action === 'sharing-review') {
|
|
891
885
|
failureLabel = 'Evidence sharing review';
|
|
892
886
|
let input;
|
|
@@ -936,6 +930,45 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
936
930
|
: terminal(formatInvestigationPlan(document), args.color));
|
|
937
931
|
return EXIT_CODES.SUCCESS;
|
|
938
932
|
}
|
|
933
|
+
if (args.action === 'workflow-run') {
|
|
934
|
+
failureLabel = 'Investigation workflow';
|
|
935
|
+
let resumeInput = null;
|
|
936
|
+
if (args.resumeSource) {
|
|
937
|
+
try {
|
|
938
|
+
resumeInput = dependencies.readDiffInput
|
|
939
|
+
? await dependencies.readDiffInput(args.resumeSource)
|
|
940
|
+
: await readSavedLookupInputBounded(createReadStream(args.resumeSource, { highWaterMark: 64 * 1024 }), {
|
|
941
|
+
limit: 24 * 1024 * 1024,
|
|
942
|
+
label: 'Investigation resume state',
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
catch (error) {
|
|
946
|
+
if (error instanceof CliUsageError)
|
|
947
|
+
throw error;
|
|
948
|
+
throw new CliUsageError(`Could not read investigation resume state: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
const document = await runInvestigationRecipe(args.recipe, args.subject, {
|
|
952
|
+
approveNetwork: args.approveNetwork,
|
|
953
|
+
resumeInput,
|
|
954
|
+
generatedAt: commandContext.now(),
|
|
955
|
+
execute: async (command, stepArguments) => {
|
|
956
|
+
const stepStdout = createBufferedOutput();
|
|
957
|
+
const stepStderr = createBufferedOutput();
|
|
958
|
+
const exitCode = await runCli([command, ...stepArguments], {
|
|
959
|
+
...dependencies,
|
|
960
|
+
stdout: stepStdout.stream,
|
|
961
|
+
stderr: stepStderr.stream,
|
|
962
|
+
});
|
|
963
|
+
return { exitCode, stdout: stepStdout.value() };
|
|
964
|
+
},
|
|
965
|
+
});
|
|
966
|
+
if (!args.quiet)
|
|
967
|
+
write(stdout, args.output === 'json'
|
|
968
|
+
? formatJsonDocument(document)
|
|
969
|
+
: terminal(formatInvestigationRun(document), args.color));
|
|
970
|
+
return document.state === 'step_failed' ? EXIT_CODES.PARTIAL_FAILURE : EXIT_CODES.SUCCESS;
|
|
971
|
+
}
|
|
939
972
|
if (args.action === 'diff') {
|
|
940
973
|
failureLabel = 'Lookup evidence diff';
|
|
941
974
|
const readDiffInput = dependencies.readDiffInput || (async (source) => (readSavedLookupInputBounded(createReadStream(source, { highWaterMark: 64 * 1024 }), {
|
|
@@ -1069,6 +1102,46 @@ async function runParsedCli(args, dependencies = {}) {
|
|
|
1069
1102
|
const { runDiscoveryScanCommand } = await import("./discovery-scan-command-runner.mjs");
|
|
1070
1103
|
return await runDiscoveryScanCommand(args, dependencies, commandContext);
|
|
1071
1104
|
}
|
|
1105
|
+
if (args.action === 'ct-intake') {
|
|
1106
|
+
failureLabel = 'Certificate event intake';
|
|
1107
|
+
let input;
|
|
1108
|
+
try {
|
|
1109
|
+
input = dependencies.readArtifactInput
|
|
1110
|
+
? await dependencies.readArtifactInput(args.source)
|
|
1111
|
+
: await readSavedLookupInputBounded(args.source
|
|
1112
|
+
? createReadStream(args.source, { highWaterMark: 64 * 1024 })
|
|
1113
|
+
: dependencies.stdin || process.stdin, {
|
|
1114
|
+
limit: MAX_CT_EVENT_INPUT_BYTES,
|
|
1115
|
+
label: 'Certificate event input',
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
catch (error) {
|
|
1119
|
+
if (error instanceof CliUsageError)
|
|
1120
|
+
throw error;
|
|
1121
|
+
throw new CliUsageError(`Could not read certificate event input: ${boundedCliErrorMessage(error, 'Input could not be read')}`);
|
|
1122
|
+
}
|
|
1123
|
+
if (!input.trim())
|
|
1124
|
+
throw new CliUsageError('ct-intake requires one versioned JSON file or a document on stdin.');
|
|
1125
|
+
let parsed;
|
|
1126
|
+
try {
|
|
1127
|
+
parsed = JSON.parse(input);
|
|
1128
|
+
}
|
|
1129
|
+
catch {
|
|
1130
|
+
throw new CliUsageError('Certificate event input is not valid JSON.');
|
|
1131
|
+
}
|
|
1132
|
+
let document;
|
|
1133
|
+
try {
|
|
1134
|
+
document = buildCtEventFindings(parsed);
|
|
1135
|
+
}
|
|
1136
|
+
catch (error) {
|
|
1137
|
+
throw new CliUsageError(boundedCliErrorMessage(error, 'Certificate event input is invalid'));
|
|
1138
|
+
}
|
|
1139
|
+
if (!args.quiet)
|
|
1140
|
+
write(stdout, args.output === 'json'
|
|
1141
|
+
? formatJsonDocument(document)
|
|
1142
|
+
: terminal(formatCtEventFindings(document), args.color));
|
|
1143
|
+
return EXIT_CODES.SUCCESS;
|
|
1144
|
+
}
|
|
1072
1145
|
if (args.action === 'ct-search'
|
|
1073
1146
|
|| args.action === 'posture'
|
|
1074
1147
|
|| args.action === 'http'
|