@knowttl/tenable-axi 0.1.4 → 0.1.6
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 +1 -1
- package/dist/src/attack-export-catalogue.js +3 -2
- package/dist/src/attack-export.js +16 -25
- package/dist/src/cli.js +13 -5
- package/dist/src/export-wait.d.ts +40 -0
- package/dist/src/export-wait.js +24 -0
- package/dist/src/exposure.d.ts +4 -0
- package/dist/src/exposure.js +12 -5
- package/dist/src/inventory-catalogue.js +8 -0
- package/dist/src/inventory-export-catalogue.js +4 -3
- package/dist/src/inventory-export.js +24 -8
- package/dist/src/inventory.js +36 -2
- package/dist/src/local-commands.js +5 -4
- package/dist/src/response-diagnostics.d.ts +19 -0
- package/dist/src/response-diagnostics.js +115 -0
- package/dist/src/setup.js +3 -3
- package/dist/src/transport-core.d.ts +51 -0
- package/dist/src/transport-core.js +9 -3
- package/dist/src/writes-core.d.ts +6 -0
- package/dist/src/writes-core.js +7 -6
- package/dist/src/writes.d.ts +6 -0
- package/docs/commands.md +39 -8
- package/package.json +1 -1
- package/skills/tenable-axi/SKILL.md +15 -4
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ The [generated command reference](https://github.com/knowttl/tenable-axi/blob/ma
|
|
|
62
62
|
| Group | Purpose | Access | Reference |
|
|
63
63
|
| --- | --- | --- | --- |
|
|
64
64
|
| `home`, `card` | Profile posture and exposure cards | Read | [Cards](https://github.com/knowttl/tenable-axi/blob/main/docs/commands.md#card-list) |
|
|
65
|
-
| `asset` | Search inventory
|
|
65
|
+
| `asset` | Search inventory, inspect assets and investigate their findings | Read | [Assets](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#inventory-reads) |
|
|
66
66
|
| `finding` | Search findings and count severity/sensor totals | Read | [Findings](https://github.com/knowttl/tenable-axi/blob/main/docs/commands.md#finding-list) |
|
|
67
67
|
| `software` | Search software and available properties | Read | [Software](https://github.com/knowttl/tenable-axi/blob/main/docs/commands.md#software-list) |
|
|
68
68
|
| `attack-path`, `attack-technique` | Investigate attack evidence | Read | [Attack paths](https://github.com/knowttl/tenable-axi/blob/main/docs/commands.md#attack-path-list) |
|
|
@@ -42,12 +42,13 @@ const global = { config: "Config path; default credential precedence", profile:
|
|
|
42
42
|
fields: "Comma-separated metadata fields; default compact view", full: "Full metadata text; default false", help: "Show help" };
|
|
43
43
|
const write = { "body-file": "Required strict operation-specific JSON file, at most 1 MiB; '-' reads stdin",
|
|
44
44
|
execute: "Create the previewed job once; default false", "dry-run": "Preview only; excludes --execute",
|
|
45
|
-
confirm: "Exact confirmation string from preview; required with --execute"
|
|
45
|
+
confirm: "Exact confirmation string from preview; required with --execute",
|
|
46
|
+
wait: "After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false" };
|
|
46
47
|
export const attackExportCatalogue = {
|
|
47
48
|
...Object.fromEntries(["attack-path", "attack-technique", "mitre-heatmap"].map((kind) => [`export ${kind} start`, {
|
|
48
49
|
description: `Preview or start one ${kind} export; requires configured write scope and ATTACK_PATH.WRITE`, operationId: `apa-export-${kind}`,
|
|
49
50
|
flags: { ...global, ...write }, defaultFields: ["id", "state"],
|
|
50
|
-
examples: [`tenable-axi export ${kind} start --body-file export.json`, `tenable-axi export ${kind} start --body-file export.json --execute --confirm '<preview-confirmation>'`], evidence: "specs/exposure-management.json",
|
|
51
|
+
examples: [`tenable-axi export ${kind} start --body-file export.json`, `tenable-axi export ${kind} start --body-file export.json --execute --confirm '<preview-confirmation>' --wait`], evidence: "specs/exposure-management.json",
|
|
51
52
|
}])),
|
|
52
53
|
"export attack status": { description: "Read an attack export job; no polling by default", operationId: "apa-export-status",
|
|
53
54
|
flags: { ...global, id: "Required attack export UUID", wait: "Poll once per second within 20-second/20-request budgets; default false" }, defaultFields: ["id", "state"],
|
|
@@ -3,6 +3,7 @@ import { closeSync, openSync, readSync } from "node:fs";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { attackExportCatalogue, attackExportCreated, attackExportInputs, attackExportStatus } from "./attack-export-catalogue.js";
|
|
5
5
|
import { exportOutputPath, saveExport } from "./export-file.js";
|
|
6
|
+
import { exportStatus } from "./export-wait.js";
|
|
6
7
|
import { createTransport, TransportError } from "./transport.js";
|
|
7
8
|
import { createWriteCoordinator } from "./writes.js";
|
|
8
9
|
export async function attackExportCommand(argv, store, transportFactory = createTransport, writeFactory = createWriteCoordinator) {
|
|
@@ -35,6 +36,12 @@ export async function attackExportCommand(argv, store, transportFactory = create
|
|
|
35
36
|
if (new Set(fields).size !== fields.length || fields.some((field) => !available.includes(field)))
|
|
36
37
|
usage(`Available fields: ${available.join(", ")}`);
|
|
37
38
|
const project = (value) => Object.fromEntries(fields.filter((key) => value[key] !== undefined).map((key) => [key, value[key]]));
|
|
39
|
+
const decode = (body, id) => {
|
|
40
|
+
const status = attackExportStatus.parse(body);
|
|
41
|
+
if (status.export_id !== id)
|
|
42
|
+
throw new TransportError({ code: "RESPONSE_INVALID", message: "Status belongs to a different attack export", operation: "apa-export-status" });
|
|
43
|
+
return { id, state: status.status, submittedAt: status.submitted_at, lastRefreshedAt: status.last_refreshed_at };
|
|
44
|
+
};
|
|
38
45
|
let body;
|
|
39
46
|
if (start) {
|
|
40
47
|
if (get("execute") && get("dry-run"))
|
|
@@ -85,7 +92,8 @@ export async function attackExportCommand(argv, store, transportFactory = create
|
|
|
85
92
|
}
|
|
86
93
|
const operation = entry.operationId;
|
|
87
94
|
if (start) {
|
|
88
|
-
const
|
|
95
|
+
const coordinator = writeFactory({ config: get("config"), profile: get("profile") });
|
|
96
|
+
const result = await coordinator.run(operation, body, { execute: !!get("execute"), dryRun: !!get("dry-run"), confirm: get("confirm") });
|
|
89
97
|
if (result.kind !== "success") {
|
|
90
98
|
let truncated = false;
|
|
91
99
|
const previewText = (value) => {
|
|
@@ -103,6 +111,11 @@ export async function attackExportCommand(argv, store, transportFactory = create
|
|
|
103
111
|
return { kind: result.kind, preview, ...(truncated ? { help: [`Run tenable-axi ${name} --body-file ${JSON.stringify(get("body-file"))} --full${get("config") ? ` --config ${JSON.stringify(get("config"))}` : ""}${get("profile") ? ` --profile ${get("profile")}` : ""} to see full preview text`] } : {}) };
|
|
104
112
|
}
|
|
105
113
|
const created = attackExportCreated.parse(result.response);
|
|
114
|
+
if (get("wait")) {
|
|
115
|
+
const status = await exportStatus(coordinator.reader, "apa-export-status", created.export_id, (body) => decode(body, created.export_id), true, { id: created.export_id, state: "SUBMITTED" });
|
|
116
|
+
return { ...status, job: project(status.job), auditId: result.auditId,
|
|
117
|
+
help: [`tenable-axi export attack status --id ${created.export_id}${get("config") ? ` --config ${JSON.stringify(get("config"))}` : ""} --profile ${result.preview.profile}`] };
|
|
118
|
+
}
|
|
106
119
|
return { job: project({ id: created.export_id, state: "SUBMITTED" }), auditId: result.auditId,
|
|
107
120
|
help: [`tenable-axi export attack status --id ${created.export_id}${get("config") ? ` --config ${JSON.stringify(get("config"))}` : ""}${get("profile") ? ` --profile ${get("profile")}` : ""}`] };
|
|
108
121
|
}
|
|
@@ -124,28 +137,6 @@ export async function attackExportCommand(argv, store, transportFactory = create
|
|
|
124
137
|
throw new TransportError({ code: "EXPORT_FILE_INVALID", message: "Export could not be validated, redacted or saved within 128 MiB to a new file", operation });
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
for (;;) {
|
|
130
|
-
let response;
|
|
131
|
-
try {
|
|
132
|
-
response = await transport.request(operation, request);
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
if (get("wait") && status && error instanceof TransportError && ["REQUEST_BUDGET_EXCEEDED", "DEADLINE_EXCEEDED"].includes(error.error.code))
|
|
136
|
-
break;
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
status = attackExportStatus.parse(response.body);
|
|
140
|
-
if (status.export_id !== get("id"))
|
|
141
|
-
throw new TransportError({ code: "RESPONSE_INVALID", message: "Status belongs to a different attack export", operation });
|
|
142
|
-
const pending = ["QUEUED", "PROCESSING"].includes(status.status);
|
|
143
|
-
if (!get("wait") || !pending || Date.now() + 1000 >= deadline)
|
|
144
|
-
break;
|
|
145
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
job: project({ id: status.export_id, state: status.status, submittedAt: status.submitted_at, lastRefreshedAt: status.last_refreshed_at }),
|
|
149
|
-
...(get("wait") && ["QUEUED", "PROCESSING"].includes(status.status) ? { complete: false, reason: "POLL_BUDGET_EXCEEDED" } : {}),
|
|
150
|
-
};
|
|
140
|
+
const status = await exportStatus(transport, operation, get("id"), (body) => decode(body, get("id")), !!get("wait"));
|
|
141
|
+
return { ...status, job: project(status.job) };
|
|
151
142
|
}
|
package/dist/src/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { encode } from "@toon-format/toon";
|
|
|
4
4
|
import { credentialStore } from "./profiles.js";
|
|
5
5
|
import { localCommand } from "./local-commands.js";
|
|
6
6
|
import { inventoryCommand } from "./inventory.js";
|
|
7
|
-
import { exposureCommand } from "./exposure.js";
|
|
7
|
+
import { exposureCommand, homeIdentity } from "./exposure.js";
|
|
8
8
|
import { TransportError } from "./transport.js";
|
|
9
9
|
import { attackCommand } from "./attack.js";
|
|
10
10
|
import { attackExportCommand } from "./attack-export.js";
|
|
@@ -22,8 +22,12 @@ export async function main(argv = process.argv.slice(2), options = {}) {
|
|
|
22
22
|
home: async () => store.redactor.payload(await exposureCommand([], store, options.transportFactory)),
|
|
23
23
|
stdout: { write: (chunk) => (options.stdout ?? process.stdout).write(store.redactor.text(chunk)) },
|
|
24
24
|
formatError: (error) => ({
|
|
25
|
-
output: `${encode(store.redactor.value(
|
|
26
|
-
|
|
25
|
+
output: `${encode(store.redactor.value({
|
|
26
|
+
...((!argv.length || argv[0] === "home" || argv[0]?.startsWith("--") && argv[0] !== "--help")
|
|
27
|
+
&& !(error instanceof AxiError && error.code === "VALIDATION_ERROR") ? homeIdentity() : {}),
|
|
28
|
+
...(error instanceof TransportError ? error.toJSON() : error instanceof AxiError ? { error: { code: error.code, message: error.message }, help: error.suggestions }
|
|
29
|
+
: { error: { code: "CONFIG_INVALID", message: "Command could not complete" } }),
|
|
30
|
+
}))}\n`,
|
|
27
31
|
exitCode: error instanceof AxiError && error.code === "VALIDATION_ERROR" ? 2 : 1,
|
|
28
32
|
}),
|
|
29
33
|
commands: {
|
|
@@ -38,8 +42,12 @@ export async function main(argv = process.argv.slice(2), options = {}) {
|
|
|
38
42
|
process.exitCode = 1;
|
|
39
43
|
return store.redactor.payload(result);
|
|
40
44
|
}
|
|
41
|
-
if (argv[0] === "export")
|
|
42
|
-
|
|
45
|
+
if (argv[0] === "export") {
|
|
46
|
+
const result = await (["attack-path", "attack-technique", "mitre-heatmap", "attack"].includes(argv[1] ?? "") ? attackExportCommand : inventoryExportCommand)(argv, store, options.transportFactory, options.writeCoordinatorFactory ?? ((flags) => createWriteCoordinator(flags, options.credentials)));
|
|
47
|
+
if (result.error)
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return store.redactor.payload(result);
|
|
50
|
+
}
|
|
43
51
|
if (["attack-path", "attack-technique", "connector"].includes(argv[0] ?? "")) {
|
|
44
52
|
const result = await attackCommand(argv, store, options.transportFactory);
|
|
45
53
|
if (result.error)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Transport } from "./transport.js";
|
|
2
|
+
export declare function exportStatus(reader: Pick<Transport, "request">, operation: string, id: string, decode: (body: unknown) => Record<string, unknown>, wait: boolean, initial?: Record<string, unknown>): Promise<{
|
|
3
|
+
job: Record<string, unknown>;
|
|
4
|
+
complete: boolean;
|
|
5
|
+
reason: string;
|
|
6
|
+
} | {
|
|
7
|
+
help?: readonly string[] | undefined;
|
|
8
|
+
error: {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
operation: string;
|
|
12
|
+
status?: number;
|
|
13
|
+
retryAfter?: number;
|
|
14
|
+
auditId?: string;
|
|
15
|
+
contentType?: string | null;
|
|
16
|
+
shape?: readonly {
|
|
17
|
+
path: string;
|
|
18
|
+
type: string;
|
|
19
|
+
count?: number;
|
|
20
|
+
expected?: string;
|
|
21
|
+
}[];
|
|
22
|
+
shapeTruncated?: boolean;
|
|
23
|
+
issues?: readonly {
|
|
24
|
+
path: string;
|
|
25
|
+
received: string;
|
|
26
|
+
expected: string;
|
|
27
|
+
code?: string;
|
|
28
|
+
pathTruncated?: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
issuePaths?: readonly string[];
|
|
31
|
+
issuePathsTruncated?: boolean;
|
|
32
|
+
};
|
|
33
|
+
job: Record<string, unknown>;
|
|
34
|
+
complete: boolean;
|
|
35
|
+
reason?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
job: Record<string, unknown>;
|
|
38
|
+
complete?: undefined;
|
|
39
|
+
reason?: undefined;
|
|
40
|
+
}>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TransportError } from "./transport.js";
|
|
2
|
+
export async function exportStatus(reader, operation, id, decode, wait, initial) {
|
|
3
|
+
const deadline = Date.now() + 19_000;
|
|
4
|
+
let job = initial;
|
|
5
|
+
for (;;) {
|
|
6
|
+
try {
|
|
7
|
+
const response = await reader.request(operation, { pathParams: { export_id: id } });
|
|
8
|
+
job = decode(response.body);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (!(error instanceof TransportError) || !wait || !job)
|
|
12
|
+
throw error;
|
|
13
|
+
if (["REQUEST_BUDGET_EXCEEDED", "DEADLINE_EXCEEDED"].includes(error.error.code)) {
|
|
14
|
+
return { job, complete: false, reason: "POLL_BUDGET_EXCEEDED" };
|
|
15
|
+
}
|
|
16
|
+
return { job, complete: false, ...error.toJSON() };
|
|
17
|
+
}
|
|
18
|
+
if (!wait || !["QUEUED", "PROCESSING"].includes(job.state))
|
|
19
|
+
return { job };
|
|
20
|
+
if (Date.now() + 1000 >= deadline)
|
|
21
|
+
return { job, complete: false, reason: "POLL_BUDGET_EXCEEDED" };
|
|
22
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
23
|
+
}
|
|
24
|
+
}
|
package/dist/src/exposure.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { credentialStore } from "./profiles.js";
|
|
2
2
|
import { type Transport, type TransportOptions } from "./transport.js";
|
|
3
3
|
export type TransportFactory = (options: TransportOptions) => Transport;
|
|
4
|
+
export declare function homeIdentity(): {
|
|
5
|
+
bin: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
4
8
|
export declare function exposureCommand(argv: string[], store: ReturnType<typeof credentialStore>, factory?: TransportFactory): Promise<Record<string, unknown>>;
|
package/dist/src/exposure.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { AxiError } from "axi-sdk-js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { closeSync, openSync, readSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { resolve, sep } from "node:path";
|
|
4
6
|
import { z } from "zod";
|
|
5
7
|
import { catalogue, DESCRIPTION, SETUP_GUIDANCE, transportBindings } from "./catalogue.js";
|
|
6
8
|
import { cardDetails, cardRecord, properties, tagRecord } from "./exposure-contracts.js";
|
|
7
9
|
import { createTransport, TransportError } from "./transport.js";
|
|
10
|
+
export function homeIdentity() {
|
|
11
|
+
const executable = resolve(process.argv[1]);
|
|
12
|
+
const home = homedir();
|
|
13
|
+
const prefix = home.endsWith(sep) ? home : `${home}${sep}`;
|
|
14
|
+
return { bin: executable.startsWith(prefix) ? `~${sep}${executable.slice(prefix.length)}` : executable, description: DESCRIPTION };
|
|
15
|
+
}
|
|
8
16
|
const operators = ["=", "!=", "<=", "between", "match", ">=", "<", ">", "contains", "not contains", "exists", "not exists", "older than", "newer than", "within last"];
|
|
9
17
|
const filterSchema = z.array(z.strictObject({ property: z.string().min(1), operator: z.enum(operators), value: z.array(z.string()) }));
|
|
10
18
|
const cardFields = ["id", "name", "score", "card_type", "is_global_card", "tag_count", "created_at", "updated_at", "sla_percentage", "ces_trend", "exposure_class", "last_data_update_date", "sources"];
|
|
@@ -26,7 +34,7 @@ const fieldTypes = {
|
|
|
26
34
|
extra_properties: z.record(z.string(), z.unknown()), weakness_severity_counts: z.record(z.string(), z.number()),
|
|
27
35
|
};
|
|
28
36
|
export async function exposureCommand(argv, store, factory = createTransport) {
|
|
29
|
-
const name = !argv.length || argv[0]?.startsWith("
|
|
37
|
+
const name = !argv.length || argv[0]?.startsWith("-") ? "home"
|
|
30
38
|
: ["card", "tag"].includes(argv[0]) ? argv.slice(0, 2).join(" ") : argv[0];
|
|
31
39
|
const entry = catalogue[name];
|
|
32
40
|
const usage = (message = "Unknown command, argument, duplicate or invalid flag") => {
|
|
@@ -38,12 +46,12 @@ export async function exposureCommand(argv, store, factory = createTransport) {
|
|
|
38
46
|
usage();
|
|
39
47
|
const flags = new Map();
|
|
40
48
|
const filters = [];
|
|
41
|
-
const start = !argv.length || argv[0]?.startsWith("
|
|
49
|
+
const start = !argv.length || argv[0]?.startsWith("-") ? 0 : name.includes(" ") ? 2 : 1;
|
|
42
50
|
for (let index = start; index < argv.length; index++) {
|
|
43
51
|
const arg = argv[index];
|
|
44
52
|
const flag = arg.slice(2);
|
|
45
53
|
if (!arg.startsWith("--") || !Object.hasOwn(entry.flags, flag) || (flags.has(flag) && flag !== "filter"))
|
|
46
|
-
usage();
|
|
54
|
+
usage(`Unknown argument, flag, or duplicate flag: ${arg}`);
|
|
47
55
|
if (["help", "full", "all"].includes(flag))
|
|
48
56
|
flags.set(flag, "true");
|
|
49
57
|
else {
|
|
@@ -193,8 +201,7 @@ export async function exposureCommand(argv, store, factory = createTransport) {
|
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
const config = flags.get("config"), selected = flags.get("profile");
|
|
196
|
-
|
|
197
|
-
const identity = { description: DESCRIPTION };
|
|
204
|
+
const identity = name === "home" ? homeIdentity() : {};
|
|
198
205
|
let profile;
|
|
199
206
|
try {
|
|
200
207
|
store.readOnly();
|
|
@@ -81,6 +81,14 @@ const search = { query: "Simple query text", filter: "Repeatable: <property> <op
|
|
|
81
81
|
"filter-file": "JSON flat array of {property, operator, value: string[]}; '-' reads stdin; excludes --filter",
|
|
82
82
|
sort: "Sortable display or wire property:asc|desc; unknown names report valid choices", "extra-properties": "Comma-separated extra wire properties", offset: "Starting record; default 0; excludes --cursor" };
|
|
83
83
|
export const inventoryCatalogue = Object.fromEntries(Object.keys(inventoryKinds).flatMap((kind) => [
|
|
84
|
+
...(kind !== "asset" ? [] : [["asset investigate", {
|
|
85
|
+
description: "Resolve a unique asset text query and read its findings within one shared invocation budget; ambiguous or incomplete lookups never pivot",
|
|
86
|
+
operationId: "inventory-findings-search", defaultFields: defaultFields.finding, evidence: "specs/exposure-management.json",
|
|
87
|
+
flags: { ...common(listFields("finding")), query: "Required asset simple query text; lookup returns at most two compact asset candidates",
|
|
88
|
+
limit: collection.limit, all: collection.all, "extra-properties": search["extra-properties"] },
|
|
89
|
+
examples: ["tenable-axi asset investigate --query example-device --limit 20",
|
|
90
|
+
"tenable-axi asset investigate --query example-device --fields id,name,severity,state,sensor_type,cves"],
|
|
91
|
+
}]]),
|
|
84
92
|
...(kind !== "finding" ? [] : [["finding summary", {
|
|
85
93
|
description: "Count findings by each published severity and sensor_type value using limit-1 searches; no per-asset grouping",
|
|
86
94
|
operationId: "inventory-findings-search", defaultFields: [], evidence: "specs/exposure-management.json",
|
|
@@ -39,9 +39,10 @@ for (const kind of ["asset", "finding"]) {
|
|
|
39
39
|
inventoryExportCatalogue[`export ${kind} start`] = { description: `Preview or create an inventory ${kind} export job`, operationId: `inventory-export-${kind}s`,
|
|
40
40
|
flags: { ...common, "body-file": "Optional strict query/filters JSON file, '-' for stdin; maximum 1 MiB", properties: `Comma-separated names from ${kind} properties; id maps to ${kind}_id`, "use-readable-name": "true|false; API default true",
|
|
41
41
|
"max-chunk-file-size": "5242880-104857600 bytes; API default 20971520", sort: "property:asc|desc", "file-format": "JSON|CSV; API default JSON", compress: "true|false; API default false",
|
|
42
|
-
execute: "Create once; default preview", "dry-run": "Explicit preview; excludes --execute", confirm: "Exact confirmation from preview", "intent-id": "Unique execution intent for replay protection"
|
|
43
|
-
|
|
42
|
+
execute: "Create once; default preview", "dry-run": "Explicit preview; excludes --execute", confirm: "Exact confirmation from preview", "intent-id": "Unique execution intent for replay protection",
|
|
43
|
+
wait: "After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false" },
|
|
44
|
+
defaultFields: ["id", "state"], examples: [`tenable-axi export ${kind} start --body-file scope.json`, `tenable-axi export ${kind} start --body-file scope.json --execute --confirm <confirmation> --wait`] };
|
|
44
45
|
inventoryExportCatalogue[`export ${kind} jobs`] = { description: `List recent inventory ${kind} export jobs`, operationId: `inventory-export-${kind}s-jobs`, flags: { ...common, status: "QUEUED|PROCESSING|FINISHED|ERROR", limit: "1-1000; default 100; last three days only" }, defaultFields: ["id", "state", "createdAt"], examples: [`tenable-axi export ${kind} jobs`, `tenable-axi export ${kind} jobs --status FINISHED --limit 10`] };
|
|
45
46
|
}
|
|
46
|
-
inventoryExportCatalogue["export inventory status"] = { description: "Read one inventory export status
|
|
47
|
+
inventoryExportCatalogue["export inventory status"] = { description: "Read one inventory export status; no polling by default", operationId: "inventory-export-status", flags: { ...common, id: "Required export UUID", wait: "Poll once per second within 20-second/20-request budgets; default false" }, defaultFields: ["id", "state", "availableChunks"], examples: ["tenable-axi export inventory status --id <id>", "tenable-axi export inventory status --id <id> --wait"] };
|
|
47
48
|
inventoryExportCatalogue["export inventory download"] = { description: "Download one inventory chunk to a new redacted file", operationId: "inventory-export-download", flags: { ...common, id: "Required export UUID", chunk: "Required nonnegative chunk number from status", output: "Required new output file; refuses overwrite" }, defaultFields: ["id", "chunk", "output", "bytes", "format", "compressed"], examples: ["tenable-axi export inventory download --id <id> --chunk 1 --output assets.json", "tenable-axi export inventory download --id <id> --chunk 2 --output assets.csv.gz"] };
|
|
@@ -3,6 +3,7 @@ import { closeSync, openSync, readSync } from "node:fs";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { exportFields, exportInput, exportState, inventoryExportCatalogue } from "./inventory-export-catalogue.js";
|
|
5
5
|
import { exportOutputPath, saveExport } from "./export-file.js";
|
|
6
|
+
import { exportStatus } from "./export-wait.js";
|
|
6
7
|
import { createTransport, TransportError } from "./transport.js";
|
|
7
8
|
import { createWriteCoordinator } from "./writes.js";
|
|
8
9
|
function bodyFile(path) {
|
|
@@ -42,7 +43,7 @@ export async function inventoryExportCommand(argv, store, factory = createTransp
|
|
|
42
43
|
const flag = argv[index];
|
|
43
44
|
if (!flag.startsWith("--") || !Object.hasOwn(entry.flags, flag.slice(2)) || flags.has(flag))
|
|
44
45
|
usage(`Unknown argument, flag, or duplicate flag: ${flag}`);
|
|
45
|
-
const value = ["--help", "--full", "--execute", "--dry-run"].includes(flag) ? "true" : argv[++index];
|
|
46
|
+
const value = ["--help", "--full", "--execute", "--dry-run", "--wait"].includes(flag) ? "true" : argv[++index];
|
|
46
47
|
if (!value || value.startsWith("--"))
|
|
47
48
|
usage(`Missing value for ${flag}`);
|
|
48
49
|
flags.set(flag, value);
|
|
@@ -64,6 +65,15 @@ export async function inventoryExportCommand(argv, store, factory = createTransp
|
|
|
64
65
|
}
|
|
65
66
|
return [field, row[field]];
|
|
66
67
|
}));
|
|
68
|
+
const decodeStatus = (body, id) => {
|
|
69
|
+
const parsed = z.object({ export_id: z.literal(id), status: exportState }).safeParse(body);
|
|
70
|
+
if (!parsed.success)
|
|
71
|
+
throw new TransportError({ code: "RESPONSE_INVALID", message: "Malformed or mismatched inventory export status", operation: "inventory-export-status" });
|
|
72
|
+
const value = body;
|
|
73
|
+
const row = { ...value, id, state: parsed.data.status, createdAt: value.submitted_at, availableChunks: value.chunks_available };
|
|
74
|
+
project(row);
|
|
75
|
+
return row;
|
|
76
|
+
};
|
|
67
77
|
if (get("execute") && get("dry-run"))
|
|
68
78
|
usage("--execute and --dry-run are mutually exclusive");
|
|
69
79
|
if (verb === "start") {
|
|
@@ -98,7 +108,8 @@ export async function inventoryExportCommand(argv, store, factory = createTransp
|
|
|
98
108
|
const input = exportInput.safeParse({ ...(body === undefined ? {} : { body }), query });
|
|
99
109
|
if (!input.success)
|
|
100
110
|
usage("Invalid export scope/options; body accepts only documented query and flat property filters");
|
|
101
|
-
const
|
|
111
|
+
const coordinator = writeFactory({ config: get("config"), profile: get("profile") });
|
|
112
|
+
const result = await coordinator.run(operation, input.data, { execute: get("execute") === "true", dryRun: get("dry-run") === "true", confirm: get("confirm"), intentId: get("intent-id") });
|
|
102
113
|
if (result.kind !== "success") {
|
|
103
114
|
let truncated = false;
|
|
104
115
|
const preview = (value) => {
|
|
@@ -116,6 +127,11 @@ export async function inventoryExportCommand(argv, store, factory = createTransp
|
|
|
116
127
|
return { ...output, ...(truncated ? { help: ["Repeat the same export command with --full to read the complete preview"] } : {}) };
|
|
117
128
|
}
|
|
118
129
|
const parsed = z.object({ export_id: z.string().uuid() }).parse(result.response);
|
|
130
|
+
if (get("wait")) {
|
|
131
|
+
const status = await exportStatus(coordinator.reader, "inventory-export-status", parsed.export_id, (body) => decodeStatus(body, parsed.export_id), true, { id: parsed.export_id, state: "QUEUED" });
|
|
132
|
+
return { ...status, job: project(status.job), auditId: result.auditId,
|
|
133
|
+
help: [`Run tenable-axi export inventory status --id ${parsed.export_id}${selectors(result.preview.profile)}`] };
|
|
134
|
+
}
|
|
119
135
|
return { job: project({ id: parsed.export_id, state: "QUEUED" }), auditId: result.auditId,
|
|
120
136
|
help: [`Run tenable-axi export inventory status --id ${parsed.export_id}${selectors(result.preview.profile)}`] };
|
|
121
137
|
}
|
|
@@ -139,25 +155,25 @@ export async function inventoryExportCommand(argv, store, factory = createTransp
|
|
|
139
155
|
store.readOnly();
|
|
140
156
|
const profile = store.select(store.load(get("config")).config, get("profile"));
|
|
141
157
|
const transport = factory({ keys: store.credentials(profile), origin: profile.origin });
|
|
158
|
+
if (verb === "status") {
|
|
159
|
+
const status = await exportStatus(transport, operation, get("id"), (body) => decodeStatus(body, get("id")), !!get("wait"));
|
|
160
|
+
return { ...status, job: project(status.job) };
|
|
161
|
+
}
|
|
142
162
|
const response = await transport.request(operation, verb === "jobs" ? { query: { limit, ...(get("status") ? { status: get("status") } : {}) } }
|
|
143
163
|
: { pathParams: { export_id: get("id"), ...(verb === "download" ? { chunk_id: get("chunk") } : {}) } });
|
|
144
164
|
if (verb === "download")
|
|
145
165
|
return { file: project({ id: get("id"), chunk: Number(get("chunk")), ...saveExport(response.body, output, store.redactor, operation) }) };
|
|
146
|
-
const decode = (row
|
|
166
|
+
const decode = (row) => {
|
|
147
167
|
const parsed = z.record(z.string(), z.unknown()).safeParse(row);
|
|
148
168
|
if (!parsed.success)
|
|
149
169
|
throw new TransportError({ code: "RESPONSE_INVALID", message: "Malformed inventory export job", operation });
|
|
150
170
|
const value = parsed.data;
|
|
151
|
-
if (status && value.export_id !== get("id"))
|
|
152
|
-
throw new TransportError({ code: "RESPONSE_INVALID", message: "Status returned another export ID", operation });
|
|
153
171
|
return project({ ...value, id: value.export_id, state: value.status, createdAt: value.submitted_at, availableChunks: value.chunks_available });
|
|
154
172
|
};
|
|
155
|
-
if (verb === "status")
|
|
156
|
-
return { job: decode(response.body, true) };
|
|
157
173
|
const rows = response.body.exports;
|
|
158
174
|
if (rows.length > limit)
|
|
159
175
|
throw new TransportError({ code: "RESPONSE_INVALID", message: "Job list exceeded the requested limit", operation });
|
|
160
|
-
return { jobs: rows.map(
|
|
176
|
+
return { jobs: rows.map(decode), count: rows.length, total: null, complete: false,
|
|
161
177
|
reason: "SERVER_HISTORY_LIMIT", ...(!rows.length ? { message: "0 export jobs matched the selected filters in the last three days" } : {}),
|
|
162
178
|
help: ["Only jobs submitted in the last three days are available; the API has no continuation",
|
|
163
179
|
`Run tenable-axi export inventory status --id <id>${selectors(profile.name)}`] };
|
package/dist/src/inventory.js
CHANGED
|
@@ -36,13 +36,13 @@ export async function inventoryCommand(argv, store, transportFactory = createTra
|
|
|
36
36
|
const usage = (message) => {
|
|
37
37
|
throw new AxiError(message, "VALIDATION_ERROR", [
|
|
38
38
|
entry ? `Valid flags for ${name}: ${Object.keys(entry.flags).map((flag) => `--${flag}`).join(", ")}`
|
|
39
|
-
: "Valid commands: asset list/show/properties, finding list/show/properties/summary, software list/properties",
|
|
39
|
+
: "Valid commands: asset list/show/properties/investigate, finding list/show/properties/summary, software list/properties",
|
|
40
40
|
]);
|
|
41
41
|
};
|
|
42
42
|
if (!entry)
|
|
43
43
|
usage("Unknown inventory command");
|
|
44
|
-
const kind = argv[0];
|
|
45
44
|
const verb = argv[1];
|
|
45
|
+
const kind = (verb === "investigate" ? "finding" : argv[0]);
|
|
46
46
|
const flags = new Map();
|
|
47
47
|
for (let index = 2; index < argv.length; index++) {
|
|
48
48
|
const flag = argv[index];
|
|
@@ -60,6 +60,8 @@ export async function inventoryCommand(argv, store, transportFactory = createTra
|
|
|
60
60
|
if (get("help"))
|
|
61
61
|
return { command: name, description: entry.description, flags: entry.flags,
|
|
62
62
|
defaultFields: entry.defaultFields, examples: entry.examples };
|
|
63
|
+
if (verb === "investigate" && !get("query"))
|
|
64
|
+
usage("--query is required to select an asset");
|
|
63
65
|
if (get("all") && get("limit"))
|
|
64
66
|
usage("--all and --limit are mutually exclusive");
|
|
65
67
|
if (get("cursor") && get("offset"))
|
|
@@ -179,6 +181,38 @@ export async function inventoryCommand(argv, store, transportFactory = createTra
|
|
|
179
181
|
if (cursor && cursor.scope !== scope)
|
|
180
182
|
usage("Cursor belongs to a different profile, operation, filters, sort, or fields");
|
|
181
183
|
const transport = transportFactory({ origin: profile.origin, keys: store.credentials(profile) });
|
|
184
|
+
if (verb === "investigate") {
|
|
185
|
+
const selectors = ["config", "profile", "full"].flatMap((flag) => get(flag) === undefined ? []
|
|
186
|
+
: flag === "full" ? ["--full"] : [`--${flag}`, get(flag)]);
|
|
187
|
+
const lookup = await inventoryCommand(["asset", "list", ...selectors, "--query", get("query"), "--limit", "2"], store, () => transport);
|
|
188
|
+
const assets = lookup.assets;
|
|
189
|
+
if (assets.length > 1)
|
|
190
|
+
return { lookup, complete: false,
|
|
191
|
+
error: { code: "ASSET_AMBIGUOUS", message: "Multiple assets matched; select an exact asset ID from the candidates" },
|
|
192
|
+
help: [`Run tenable-axi finding list --filter 'asset_id = ["<asset-id>"]' ${selectors.map(quote).join(" ")}`.trim()] };
|
|
193
|
+
if (!lookup.complete)
|
|
194
|
+
return { lookup, complete: false, reason: lookup.reason,
|
|
195
|
+
...(lookup.error ? { error: lookup.error } : {}) };
|
|
196
|
+
if (!assets.length)
|
|
197
|
+
return { lookup, complete: false,
|
|
198
|
+
error: { code: "NOT_FOUND", message: "No asset matched the selected query" } };
|
|
199
|
+
const asset = assets[0];
|
|
200
|
+
if (typeof asset.id !== "string" || !asset.id.length)
|
|
201
|
+
throw new TransportError({ code: "RESPONSE_INVALID",
|
|
202
|
+
message: "Asset lookup is missing the pivot identifier", operation: "inventory-assets-search" });
|
|
203
|
+
const findingFlags = ["fields", "extra-properties", "limit", "all"].flatMap((flag) => get(flag) === undefined ? []
|
|
204
|
+
: flag === "all" ? ["--all"] : [`--${flag}`, get(flag)]);
|
|
205
|
+
try {
|
|
206
|
+
const findings = await inventoryCommand(["finding", "list", ...selectors, ...findingFlags,
|
|
207
|
+
"--filter", `asset_id = ${JSON.stringify([asset.id])}`], store, () => transport);
|
|
208
|
+
return { asset, lookup, ...findings };
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (!(error instanceof TransportError))
|
|
212
|
+
throw error;
|
|
213
|
+
return { asset, lookup, findings: [], count: 0, total: null, complete: false, reason: "READ_FAILED", ...error.toJSON() };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
182
216
|
if (verb === "summary") {
|
|
183
217
|
const counts = { severity: [], sensor_type: [] };
|
|
184
218
|
try {
|
|
@@ -3,9 +3,10 @@ import { catalogue } from "./catalogue.js";
|
|
|
3
3
|
export function localCommand(argv, store) {
|
|
4
4
|
const name = argv.slice(0, 2).join(" ");
|
|
5
5
|
const entry = catalogue[name];
|
|
6
|
-
const usage = () => {
|
|
7
|
-
throw new AxiError(
|
|
8
|
-
|
|
6
|
+
const usage = (message = "Unknown command, argument, duplicate or invalid flag") => {
|
|
7
|
+
throw new AxiError(message, "VALIDATION_ERROR", [
|
|
8
|
+
entry ? `Valid flags for ${name}: ${Object.keys(entry.flags).map((flag) => `--${flag}`).join(", ")}`
|
|
9
|
+
: "Valid commands: auth status, profile list, config path; valid flags: --config <path>, --profile <name>, --fields <names>, --full, --help",
|
|
9
10
|
]);
|
|
10
11
|
};
|
|
11
12
|
if (!entry || name === "home")
|
|
@@ -14,7 +15,7 @@ export function localCommand(argv, store) {
|
|
|
14
15
|
for (let index = 2; index < argv.length; index++) {
|
|
15
16
|
const flag = argv[index];
|
|
16
17
|
if (!flag.startsWith("--") || !Object.hasOwn(entry.flags, flag.slice(2)) || flags.has(flag))
|
|
17
|
-
usage();
|
|
18
|
+
usage(`Unknown argument, flag, or duplicate flag: ${flag}`);
|
|
18
19
|
if (flag === "--help" || flag === "--full")
|
|
19
20
|
flags.set(flag, "true");
|
|
20
21
|
else {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type DiagnosticRedactor = {
|
|
2
|
+
text(value: string): string;
|
|
3
|
+
};
|
|
4
|
+
export declare class ResponseDiagnostics {
|
|
5
|
+
private readonly redactor;
|
|
6
|
+
private readonly errorCodes;
|
|
7
|
+
private details;
|
|
8
|
+
private readonly shapeByPath;
|
|
9
|
+
private data;
|
|
10
|
+
constructor(redactor: DiagnosticRedactor, errorCodes?: readonly string[]);
|
|
11
|
+
record(status: number, headers: Headers, data: unknown): void;
|
|
12
|
+
validationFailed(issues: readonly {
|
|
13
|
+
path: readonly PropertyKey[];
|
|
14
|
+
expected?: unknown;
|
|
15
|
+
code?: unknown;
|
|
16
|
+
}[]): void;
|
|
17
|
+
private shape;
|
|
18
|
+
forError(error: unknown): Record<string, unknown>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const issueCodes = new Set(["invalid_type", "too_big", "too_small", "invalid_format", "not_multiple_of", "unrecognized_keys", "invalid_union", "invalid_key", "invalid_element", "invalid_value", "custom"]);
|
|
2
|
+
const types = new Set(["string", "number", "boolean", "object", "array", "null", "undefined", "bigint", "symbol", "function", "date", "int", "unknown", "never", "void"]);
|
|
3
|
+
function valueType(value) {
|
|
4
|
+
return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
|
|
5
|
+
}
|
|
6
|
+
function keySegment(key, redactor) {
|
|
7
|
+
const identifier = /^[A-Za-z][A-Za-z0-9_]{0,39}$/.test(key);
|
|
8
|
+
const guid = /^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:[-_][0-9a-f]{4}){3}[-_][0-9a-f]{12})$/i.test(key);
|
|
9
|
+
return `[${JSON.stringify(identifier && !guid ? redactor.text(key) : "<key>")}]`;
|
|
10
|
+
}
|
|
11
|
+
// Emit structure only, never the response body or validation-library errors.
|
|
12
|
+
export class ResponseDiagnostics {
|
|
13
|
+
redactor;
|
|
14
|
+
errorCodes;
|
|
15
|
+
details = {};
|
|
16
|
+
shapeByPath = new Map();
|
|
17
|
+
data;
|
|
18
|
+
constructor(redactor, errorCodes = ["API_RESPONSE_INVALID", "AUTH_RESPONSE_INVALID"]) {
|
|
19
|
+
this.redactor = redactor;
|
|
20
|
+
this.errorCodes = errorCodes;
|
|
21
|
+
}
|
|
22
|
+
record(status, headers, data) {
|
|
23
|
+
this.data = data;
|
|
24
|
+
// Parameters can contain arbitrary server text; report only the bounded media type.
|
|
25
|
+
const mediaType = headers.get("content-type")?.split(";", 1)[0]?.trim();
|
|
26
|
+
const contentType = mediaType && mediaType.length <= 128 && /^[a-z0-9!#$&^_.+\-]+\/[a-z0-9!#$&^_.+\-]+$/i.test(mediaType)
|
|
27
|
+
? this.redactor.text(mediaType) : null;
|
|
28
|
+
this.details = { status: Number.isInteger(status) && status >= 100 && status <= 599 ? status : null, contentType, ...this.shape(data) };
|
|
29
|
+
}
|
|
30
|
+
validationFailed(issues) {
|
|
31
|
+
const issuePaths = [];
|
|
32
|
+
const annotations = [];
|
|
33
|
+
let truncated = false;
|
|
34
|
+
let characters = 0;
|
|
35
|
+
for (const issue of issues) {
|
|
36
|
+
let path = "$";
|
|
37
|
+
for (const [depth, key] of issue.path.entries()) {
|
|
38
|
+
if (depth >= 4) {
|
|
39
|
+
truncated = true;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
path += typeof key === "number" && Number.isSafeInteger(key) && key >= 0 ? "[*]" : keySegment(String(key), this.redactor);
|
|
43
|
+
}
|
|
44
|
+
if (issuePaths.length >= 64 || path.length > 256 || characters + path.length > 4096) {
|
|
45
|
+
truncated = true;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
characters += path.length;
|
|
49
|
+
issuePaths.push(path);
|
|
50
|
+
let received = this.data;
|
|
51
|
+
for (const key of issue.path) {
|
|
52
|
+
received = received !== null && typeof received === "object" && Object.hasOwn(received, key)
|
|
53
|
+
? received[key] : undefined;
|
|
54
|
+
}
|
|
55
|
+
const expected = typeof issue.expected === "string" && types.has(issue.expected) ? issue.expected : "unknown";
|
|
56
|
+
annotations.push({ path, received: valueType(received), expected, ...(typeof issue.code === "string" && issueCodes.has(issue.code) ? { code: issue.code } : {}), ...(truncated ? { pathTruncated: true } : {}) });
|
|
57
|
+
// Validator messages and arbitrary expected strings can contain response values.
|
|
58
|
+
// Annotate only types from the contract vocabulary, on the recorded received shape.
|
|
59
|
+
if (!truncated && typeof issue.expected === "string" && types.has(issue.expected)) {
|
|
60
|
+
const entry = this.shapeByPath.get(JSON.stringify(issue.path));
|
|
61
|
+
if (entry)
|
|
62
|
+
entry.expected = issue.expected;
|
|
63
|
+
}
|
|
64
|
+
if (truncated)
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
this.details = { ...this.details, issues: annotations, issuePaths, issuePathsTruncated: truncated };
|
|
68
|
+
}
|
|
69
|
+
shape(data) {
|
|
70
|
+
this.shapeByPath.clear();
|
|
71
|
+
const shape = [];
|
|
72
|
+
let truncated = false;
|
|
73
|
+
let characters = 0;
|
|
74
|
+
const visit = (value, path, keys) => {
|
|
75
|
+
if (shape.length >= 64 || path.length > 256 || characters + path.length > 4096) {
|
|
76
|
+
truncated = true;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
characters += path.length;
|
|
80
|
+
const type = valueType(value);
|
|
81
|
+
const entry = { path, type, ...(Array.isArray(value) ? { count: value.length } : {}) };
|
|
82
|
+
shape.push(entry);
|
|
83
|
+
this.shapeByPath.set(JSON.stringify(keys), entry);
|
|
84
|
+
if (value === null || typeof value !== "object")
|
|
85
|
+
return;
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
if (value.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
if (keys.length >= 4) {
|
|
90
|
+
truncated = true;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
visit(value[0], path + "[*]", [...keys, 0]);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
for (const key in value) {
|
|
97
|
+
if (!Object.hasOwn(value, key))
|
|
98
|
+
continue;
|
|
99
|
+
if (keys.length >= 4 || shape.length >= 64) {
|
|
100
|
+
truncated = true;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
const segment = keySegment(key, this.redactor);
|
|
104
|
+
visit(value[key], path + segment, [...keys, key]);
|
|
105
|
+
if (truncated)
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
visit(data, "$", []);
|
|
110
|
+
return { shape, shapeTruncated: truncated };
|
|
111
|
+
}
|
|
112
|
+
forError(error) {
|
|
113
|
+
return error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" && this.errorCodes.includes(error.code) ? this.details : {};
|
|
114
|
+
}
|
|
115
|
+
}
|
package/dist/src/setup.js
CHANGED
|
@@ -4,8 +4,8 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { catalogue } from "./catalogue.js";
|
|
5
5
|
import { installHooks } from "./hook-install.js";
|
|
6
6
|
export function setupHooks(argv) {
|
|
7
|
-
const usage = () => {
|
|
8
|
-
throw new AxiError(
|
|
7
|
+
const usage = (message = "Invalid hook setup command or flags") => {
|
|
8
|
+
throw new AxiError(message, "VALIDATION_ERROR", [
|
|
9
9
|
"Valid commands: setup hooks; valid flags: --scope user|project, --help",
|
|
10
10
|
]);
|
|
11
11
|
};
|
|
@@ -16,7 +16,7 @@ export function setupHooks(argv) {
|
|
|
16
16
|
for (let index = 2; index < argv.length; index++) {
|
|
17
17
|
const flag = argv[index];
|
|
18
18
|
if (!["--help", "--scope"].includes(flag) || seen.has(flag))
|
|
19
|
-
usage();
|
|
19
|
+
usage(`Unknown argument, flag, or duplicate flag: ${flag}`);
|
|
20
20
|
seen.add(flag);
|
|
21
21
|
if (flag === "--scope") {
|
|
22
22
|
const value = argv[++index];
|
|
@@ -50,6 +50,23 @@ export declare class TransportError extends Error {
|
|
|
50
50
|
status?: number;
|
|
51
51
|
retryAfter?: number;
|
|
52
52
|
auditId?: string;
|
|
53
|
+
contentType?: string | null;
|
|
54
|
+
shape?: readonly {
|
|
55
|
+
path: string;
|
|
56
|
+
type: string;
|
|
57
|
+
count?: number;
|
|
58
|
+
expected?: string;
|
|
59
|
+
}[];
|
|
60
|
+
shapeTruncated?: boolean;
|
|
61
|
+
issues?: readonly {
|
|
62
|
+
path: string;
|
|
63
|
+
received: string;
|
|
64
|
+
expected: string;
|
|
65
|
+
code?: string;
|
|
66
|
+
pathTruncated?: boolean;
|
|
67
|
+
}[];
|
|
68
|
+
issuePaths?: readonly string[];
|
|
69
|
+
issuePathsTruncated?: boolean;
|
|
53
70
|
};
|
|
54
71
|
readonly help: readonly string[];
|
|
55
72
|
constructor(error: {
|
|
@@ -59,6 +76,23 @@ export declare class TransportError extends Error {
|
|
|
59
76
|
status?: number;
|
|
60
77
|
retryAfter?: number;
|
|
61
78
|
auditId?: string;
|
|
79
|
+
contentType?: string | null;
|
|
80
|
+
shape?: readonly {
|
|
81
|
+
path: string;
|
|
82
|
+
type: string;
|
|
83
|
+
count?: number;
|
|
84
|
+
expected?: string;
|
|
85
|
+
}[];
|
|
86
|
+
shapeTruncated?: boolean;
|
|
87
|
+
issues?: readonly {
|
|
88
|
+
path: string;
|
|
89
|
+
received: string;
|
|
90
|
+
expected: string;
|
|
91
|
+
code?: string;
|
|
92
|
+
pathTruncated?: boolean;
|
|
93
|
+
}[];
|
|
94
|
+
issuePaths?: readonly string[];
|
|
95
|
+
issuePathsTruncated?: boolean;
|
|
62
96
|
}, help?: readonly string[]);
|
|
63
97
|
toJSON(): {
|
|
64
98
|
help?: readonly string[] | undefined;
|
|
@@ -69,6 +103,23 @@ export declare class TransportError extends Error {
|
|
|
69
103
|
status?: number;
|
|
70
104
|
retryAfter?: number;
|
|
71
105
|
auditId?: string;
|
|
106
|
+
contentType?: string | null;
|
|
107
|
+
shape?: readonly {
|
|
108
|
+
path: string;
|
|
109
|
+
type: string;
|
|
110
|
+
count?: number;
|
|
111
|
+
expected?: string;
|
|
112
|
+
}[];
|
|
113
|
+
shapeTruncated?: boolean;
|
|
114
|
+
issues?: readonly {
|
|
115
|
+
path: string;
|
|
116
|
+
received: string;
|
|
117
|
+
expected: string;
|
|
118
|
+
code?: string;
|
|
119
|
+
pathTruncated?: boolean;
|
|
120
|
+
}[];
|
|
121
|
+
issuePaths?: readonly string[];
|
|
122
|
+
issuePathsTruncated?: boolean;
|
|
72
123
|
};
|
|
73
124
|
};
|
|
74
125
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResponseDiagnostics } from "./response-diagnostics.js";
|
|
1
2
|
export const TENABLE_ORIGIN = "https://cloud.tenable.com";
|
|
2
3
|
export class TransportError extends Error {
|
|
3
4
|
error;
|
|
@@ -188,15 +189,20 @@ export function constructTransport(options, dependencies) {
|
|
|
188
189
|
return { status: response.status, body: file };
|
|
189
190
|
}
|
|
190
191
|
let decoded;
|
|
192
|
+
const diagnostics = new ResponseDiagnostics({ text: redact }, ["RESPONSE_INVALID"]);
|
|
191
193
|
try {
|
|
192
194
|
decoded = text ? JSON.parse(text) : undefined;
|
|
193
195
|
}
|
|
194
196
|
catch {
|
|
195
|
-
|
|
197
|
+
diagnostics.record(response.status, response.headers, text);
|
|
198
|
+
fail("RESPONSE_INVALID", "Tenable response is not valid JSON", operation, [], diagnostics.forError({ code: "RESPONSE_INVALID" }));
|
|
196
199
|
}
|
|
197
200
|
const result = record.decoder.safeParse(decoded);
|
|
198
|
-
if (!result.success)
|
|
199
|
-
|
|
201
|
+
if (!result.success) {
|
|
202
|
+
diagnostics.record(response.status, response.headers, decoded);
|
|
203
|
+
diagnostics.validationFailed(result.error.issues);
|
|
204
|
+
fail("RESPONSE_INVALID", "Tenable response does not match the selected view", operation, ["Check the operation response contract; no result was inferred"], diagnostics.forError({ code: "RESPONSE_INVALID" }));
|
|
205
|
+
}
|
|
200
206
|
return { status: response.status, body: result.data };
|
|
201
207
|
}
|
|
202
208
|
const status = response.status;
|
|
@@ -109,4 +109,10 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
|
|
|
109
109
|
status: number;
|
|
110
110
|
response: unknown;
|
|
111
111
|
}>;
|
|
112
|
+
reader: {
|
|
113
|
+
request: (name: string, options?: RequestOptions) => Promise<{
|
|
114
|
+
status: number;
|
|
115
|
+
body: unknown;
|
|
116
|
+
}>;
|
|
117
|
+
};
|
|
112
118
|
};
|
package/dist/src/writes-core.js
CHANGED
|
@@ -64,6 +64,12 @@ export function constructWriteCoordinator(options, dependencies) {
|
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
const reader = { request: async (name, options) => {
|
|
68
|
+
const connection = sender();
|
|
69
|
+
if (connection.prepare(name, options).effect !== "read")
|
|
70
|
+
fail("OPERATION_BLOCKED", "State readers cannot send writes", name);
|
|
71
|
+
return connection.request(name, options);
|
|
72
|
+
} };
|
|
67
73
|
function fail(code, message, operation, help = [], auditId) {
|
|
68
74
|
throw new TransportError({ code, message, operation, ...(auditId ? { auditId } : {}) }, help);
|
|
69
75
|
}
|
|
@@ -155,11 +161,6 @@ export function constructWriteCoordinator(options, dependencies) {
|
|
|
155
161
|
const { effect: _effect, ...identity } = plan;
|
|
156
162
|
const confirmationTarget = "payload" in target ? { kind: target.kind, digest: digest(canonical(request)) } : target;
|
|
157
163
|
const confirm = canonical([scope.profile, operation, confirmationTarget]);
|
|
158
|
-
const reader = { request: async (name, options) => {
|
|
159
|
-
if (connection.prepare(name, options).effect !== "read")
|
|
160
|
-
fail("OPERATION_BLOCKED", "State readers cannot send writes", operation);
|
|
161
|
-
return connection.request(name, options);
|
|
162
|
-
} };
|
|
163
164
|
const current = await definition.current?.(reader, parsed.data);
|
|
164
165
|
const state = canonical(current?.state ?? null);
|
|
165
166
|
const preview = store.redactor.payload({ profile: scope.profile, operation, target, effect: definition.effect,
|
|
@@ -211,5 +212,5 @@ export function constructWriteCoordinator(options, dependencies) {
|
|
|
211
212
|
append("outcome", "SUCCESS", response.status);
|
|
212
213
|
return { kind: "success", preview, auditId, status: response.status, response: store.redactor.payload(response.body) };
|
|
213
214
|
}
|
|
214
|
-
return { scope, run };
|
|
215
|
+
return { scope, run, reader };
|
|
215
216
|
}
|
package/dist/src/writes.d.ts
CHANGED
|
@@ -54,4 +54,10 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
|
|
|
54
54
|
status: number;
|
|
55
55
|
response: unknown;
|
|
56
56
|
}>;
|
|
57
|
+
reader: {
|
|
58
|
+
request: (name: string, options?: import("./transport-core.js").RequestOptions) => Promise<{
|
|
59
|
+
status: number;
|
|
60
|
+
body: unknown;
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
57
63
|
};
|
package/docs/commands.md
CHANGED
|
@@ -6,6 +6,7 @@ Investigate Tenable One exposure and run explicitly guarded writes.
|
|
|
6
6
|
|
|
7
7
|
## Contents
|
|
8
8
|
|
|
9
|
+
- [asset investigate](#asset-investigate)
|
|
9
10
|
- [asset list](#asset-list)
|
|
10
11
|
- [asset properties](#asset-properties)
|
|
11
12
|
- [asset show](#asset-show)
|
|
@@ -72,6 +73,7 @@ Investigate Tenable One exposure and run explicitly guarded writes.
|
|
|
72
73
|
|
|
73
74
|
| Command | Purpose |
|
|
74
75
|
|---|---|
|
|
76
|
+
| `tenable-axi asset investigate` | Resolve a unique asset text query and read its findings within one shared invocation budget; ambiguous or incomplete lookups never pivot |
|
|
75
77
|
| `tenable-axi asset list` | Search assets |
|
|
76
78
|
| `tenable-axi asset properties` | Discover asset properties and supported operators |
|
|
77
79
|
| `tenable-axi asset show` | Find one asset by exact ID search |
|
|
@@ -98,7 +100,7 @@ Investigate Tenable One exposure and run explicitly guarded writes.
|
|
|
98
100
|
| `tenable-axi export finding jobs` | List recent inventory finding export jobs |
|
|
99
101
|
| `tenable-axi export finding start` | Preview or create an inventory finding export job |
|
|
100
102
|
| `tenable-axi export inventory download` | Download one inventory chunk to a new redacted file |
|
|
101
|
-
| `tenable-axi export inventory status` | Read one inventory export status
|
|
103
|
+
| `tenable-axi export inventory status` | Read one inventory export status; no polling by default |
|
|
102
104
|
| `tenable-axi export mitre-heatmap start` | Preview or start one mitre-heatmap export; requires configured write scope and ATTACK_PATH.WRITE |
|
|
103
105
|
| `tenable-axi finding list` | Search findings |
|
|
104
106
|
| `tenable-axi finding properties` | Discover finding properties and supported operators |
|
|
@@ -137,6 +139,29 @@ Investigate Tenable One exposure and run explicitly guarded writes.
|
|
|
137
139
|
Run each command with `--help` for concise help.
|
|
138
140
|
Writes default to preview and require configured operation scope even for previews.
|
|
139
141
|
|
|
142
|
+
## asset investigate
|
|
143
|
+
|
|
144
|
+
Resolve a unique asset text query and read its findings within one shared invocation budget; ambiguous or incomplete lookups never pivot
|
|
145
|
+
|
|
146
|
+
Operation: `inventory-findings-search`.
|
|
147
|
+
|
|
148
|
+
| Flag | Meaning |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `--config` | Config path; default credential precedence |
|
|
151
|
+
| `--profile` | Profile name; default credential precedence |
|
|
152
|
+
| `--fields` | Comma-separated display or wire properties; display names: id, name, severity, state, sensor_type; default compact view |
|
|
153
|
+
| `--full` | Show untruncated text; does not add fields or rows; default false |
|
|
154
|
+
| `--help` | Show help |
|
|
155
|
+
| `--query` | Required asset simple query text; lookup returns at most two compact asset candidates |
|
|
156
|
+
| `--limit` | Maximum emitted rows, 1-10000; default 100 |
|
|
157
|
+
| `--all` | Read up to 10000 rows within invocation budgets; excludes --limit |
|
|
158
|
+
| `--extra-properties` | Comma-separated extra wire properties |
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
tenable-axi asset investigate --query example-device --limit 20
|
|
162
|
+
tenable-axi asset investigate --query example-device --fields id,name,severity,state,sensor_type,cves
|
|
163
|
+
```
|
|
164
|
+
|
|
140
165
|
## asset list
|
|
141
166
|
|
|
142
167
|
Search assets
|
|
@@ -571,10 +596,11 @@ Operation: `inventory-export-assets`.
|
|
|
571
596
|
| `--dry-run` | Explicit preview; excludes --execute |
|
|
572
597
|
| `--confirm` | Exact confirmation from preview |
|
|
573
598
|
| `--intent-id` | Unique execution intent for replay protection |
|
|
599
|
+
| `--wait` | After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false |
|
|
574
600
|
|
|
575
601
|
```sh
|
|
576
602
|
tenable-axi export asset start --body-file scope.json
|
|
577
|
-
tenable-axi export asset start --body-file scope.json --execute --confirm <confirmation>
|
|
603
|
+
tenable-axi export asset start --body-file scope.json --execute --confirm <confirmation> --wait
|
|
578
604
|
```
|
|
579
605
|
|
|
580
606
|
## export attack download
|
|
@@ -636,10 +662,11 @@ Operation: `apa-export-attack-path`.
|
|
|
636
662
|
| `--execute` | Create the previewed job once; default false |
|
|
637
663
|
| `--dry-run` | Preview only; excludes --execute |
|
|
638
664
|
| `--confirm` | Exact confirmation string from preview; required with --execute |
|
|
665
|
+
| `--wait` | After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false |
|
|
639
666
|
|
|
640
667
|
```sh
|
|
641
668
|
tenable-axi export attack-path start --body-file export.json
|
|
642
|
-
tenable-axi export attack-path start --body-file export.json --execute --confirm '<preview-confirmation>'
|
|
669
|
+
tenable-axi export attack-path start --body-file export.json --execute --confirm '<preview-confirmation>' --wait
|
|
643
670
|
```
|
|
644
671
|
|
|
645
672
|
## export attack-technique start
|
|
@@ -659,10 +686,11 @@ Operation: `apa-export-attack-technique`.
|
|
|
659
686
|
| `--execute` | Create the previewed job once; default false |
|
|
660
687
|
| `--dry-run` | Preview only; excludes --execute |
|
|
661
688
|
| `--confirm` | Exact confirmation string from preview; required with --execute |
|
|
689
|
+
| `--wait` | After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false |
|
|
662
690
|
|
|
663
691
|
```sh
|
|
664
692
|
tenable-axi export attack-technique start --body-file export.json
|
|
665
|
-
tenable-axi export attack-technique start --body-file export.json --execute --confirm '<preview-confirmation>'
|
|
693
|
+
tenable-axi export attack-technique start --body-file export.json --execute --confirm '<preview-confirmation>' --wait
|
|
666
694
|
```
|
|
667
695
|
|
|
668
696
|
## export finding jobs
|
|
@@ -710,10 +738,11 @@ Operation: `inventory-export-findings`.
|
|
|
710
738
|
| `--dry-run` | Explicit preview; excludes --execute |
|
|
711
739
|
| `--confirm` | Exact confirmation from preview |
|
|
712
740
|
| `--intent-id` | Unique execution intent for replay protection |
|
|
741
|
+
| `--wait` | After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false |
|
|
713
742
|
|
|
714
743
|
```sh
|
|
715
744
|
tenable-axi export finding start --body-file scope.json
|
|
716
|
-
tenable-axi export finding start --body-file scope.json --execute --confirm <confirmation>
|
|
745
|
+
tenable-axi export finding start --body-file scope.json --execute --confirm <confirmation> --wait
|
|
717
746
|
```
|
|
718
747
|
|
|
719
748
|
## export inventory download
|
|
@@ -740,7 +769,7 @@ tenable-axi export inventory download --id <id> --chunk 2 --output assets.csv.gz
|
|
|
740
769
|
|
|
741
770
|
## export inventory status
|
|
742
771
|
|
|
743
|
-
Read one inventory export status
|
|
772
|
+
Read one inventory export status; no polling by default
|
|
744
773
|
|
|
745
774
|
Operation: `inventory-export-status`.
|
|
746
775
|
|
|
@@ -752,10 +781,11 @@ Operation: `inventory-export-status`.
|
|
|
752
781
|
| `--full` | Full output; default false |
|
|
753
782
|
| `--help` | Show help |
|
|
754
783
|
| `--id` | Required export UUID |
|
|
784
|
+
| `--wait` | Poll once per second within 20-second/20-request budgets; default false |
|
|
755
785
|
|
|
756
786
|
```sh
|
|
757
787
|
tenable-axi export inventory status --id <id>
|
|
758
|
-
tenable-axi export inventory status --id <id> --
|
|
788
|
+
tenable-axi export inventory status --id <id> --wait
|
|
759
789
|
```
|
|
760
790
|
|
|
761
791
|
## export mitre-heatmap start
|
|
@@ -775,10 +805,11 @@ Operation: `apa-export-mitre-heatmap`.
|
|
|
775
805
|
| `--execute` | Create the previewed job once; default false |
|
|
776
806
|
| `--dry-run` | Preview only; excludes --execute |
|
|
777
807
|
| `--confirm` | Exact confirmation string from preview; required with --execute |
|
|
808
|
+
| `--wait` | After confirmed creation, poll within the shared 20-second/20-request budgets; never creates a replacement; default false |
|
|
778
809
|
|
|
779
810
|
```sh
|
|
780
811
|
tenable-axi export mitre-heatmap start --body-file export.json
|
|
781
|
-
tenable-axi export mitre-heatmap start --body-file export.json --execute --confirm '<preview-confirmation>'
|
|
812
|
+
tenable-axi export mitre-heatmap start --body-file export.json --execute --confirm '<preview-confirmation>' --wait
|
|
782
813
|
```
|
|
783
814
|
|
|
784
815
|
## finding list
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ The fields shown are useful compact projections; omit `--fields` for the command
|
|
|
25
25
|
|---|---|
|
|
26
26
|
| Check credentials locally, without HTTP | `npx -y @knowttl/tenable-axi auth status` |
|
|
27
27
|
| Look up an asset by text | `npx -y @knowttl/tenable-axi asset list --query example-device --class DEVICE --limit 10 --fields id,name,class,exposureScore` |
|
|
28
|
+
| Resolve a unique asset and read its findings | `npx -y @knowttl/tenable-axi asset investigate --query example-device --limit 20 --fields id,name,severity,state,sensor_type,cves` |
|
|
28
29
|
| Read one exact asset, including observation evidence | `npx -y @knowttl/tenable-axi asset show --id asset-1 --fields id,name,fqdns,last_observed_at` |
|
|
29
30
|
| Pivot from an asset ID to findings | `npx -y @knowttl/tenable-axi finding list --filter 'asset_id = ["asset-1"]' --limit 20 --fields id,name,severity,state,sensor_type,cves` |
|
|
30
31
|
| Search high severity findings | `npx -y @knowttl/tenable-axi finding list --filter 'severity = ["HIGH"]' --filter 'sensor_type = ["NESSUS"]' --limit 20` |
|
|
@@ -40,6 +41,7 @@ The fields shown are useful compact projections; omit `--fields` for the command
|
|
|
40
41
|
| Find Exposure Management tags | `npx -y @knowttl/tenable-axi tag list --query example --limit 10` |
|
|
41
42
|
| Diagnose failed connector syncs | `npx -y @knowttl/tenable-axi connector logs --status FAILED --start-date 2026-01-01 --end-date 2026-02-01 --limit 10` |
|
|
42
43
|
| Wait for an existing attack export | `npx -y @knowttl/tenable-axi export attack status --id 00000000-0000-4000-8000-000000000001 --wait` |
|
|
44
|
+
| Wait for an existing inventory export | `npx -y @knowttl/tenable-axi export inventory status --id 00000000-0000-4000-8000-000000000001 --wait` |
|
|
43
45
|
|
|
44
46
|
Inventory filters are repeatable AND conditions with a JSON array of strings, even for numeric values.
|
|
45
47
|
Inventory `--filter-file` accepts a flat JSON array and excludes `--filter`.
|
|
@@ -52,6 +54,11 @@ Connector defaults include sync identity, trigger, first failed stage and first
|
|
|
52
54
|
Use list `--fields` to retrieve the needed evidence together instead of showing every result.
|
|
53
55
|
Inventory selected extra fields are requested automatically; `--extra-properties` also adds them to output.
|
|
54
56
|
Exact-ID `asset show` and `finding show` search directly without a preceding list.
|
|
57
|
+
`asset investigate --query <text>` returns compact asset candidates in `lookup` and pivots only after a complete, unique match.
|
|
58
|
+
Multiple candidates return `ASSET_AMBIGUOUS`; choose an exact ID explicitly before using `finding list`.
|
|
59
|
+
`--fields`, `--extra-properties`, `--limit` and `--all` control findings; asset evidence uses compact defaults.
|
|
60
|
+
Lookup and findings share one invocation budget; failures retain validated evidence and disclose incompleteness.
|
|
61
|
+
Resume a returned findings cursor with the suggested `finding list` command, preserving its asset filter and fields.
|
|
55
62
|
`finding summary` is one CLI call making 19 sequential limit-1 reads without retries, using upstream totals.
|
|
56
63
|
It has no filters or per-asset grouping; counts are independent, sensor values may overlap, and `complete: false` means partial counts.
|
|
57
64
|
|
|
@@ -62,14 +69,18 @@ Resume a returned `--cursor` with the same profile, filters, fields and sort; do
|
|
|
62
69
|
`--full` removes the 1,000-character text preview, without adding fields, rows or budget.
|
|
63
70
|
Connector logs have no server paging; `UPSTREAM_UNPAGED` means unavailable history, not an exhaustive empty result.
|
|
64
71
|
|
|
65
|
-
Attack export status `--wait`
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
Attack and inventory export status `--wait` poll once per second within 20 seconds/20 requests; inspect the returned state before downloading.
|
|
73
|
+
Pending jobs returned after a wait budget ends carry `complete: false` and `reason: POLL_BUDGET_EXCEEDED`; resume status with the same exact ID rather than starting a replacement.
|
|
74
|
+
There is no bulk show command.
|
|
75
|
+
Use a filtered list for multiple details.
|
|
68
76
|
Software has no stable ID or show command.
|
|
69
77
|
|
|
70
78
|
## Read allowlist and state changes
|
|
71
79
|
|
|
72
80
|
The table above is read-only, including POST searches and waiting on an existing export.
|
|
81
|
+
Export start commands accept `--wait` after `--execute --confirm '<exact-preview-confirmation>'`, sharing the creation deadline and request budget.
|
|
82
|
+
Preview, configured operation scope and the durable journal remain required; previews never poll, creation sends at most once and unknown outcomes never start a replacement.
|
|
83
|
+
A failed status read after creation retains the created job and audit ID with `complete: false` and an error; reconcile that ID instead of creating again.
|
|
73
84
|
Other remote reads: `home`, `card show`, `tag properties`, platform `tag category/value list/show`, `tag assignment/exclusion/asset-filter list`, `initiative list/show`, `combination list/show/filters`, `export asset/finding jobs`, `export inventory status` and `doctor`.
|
|
74
85
|
`doctor` makes eight module probes without retries; use it for access diagnosis, not before each case.
|
|
75
86
|
Local reads: `auth status`, `profile list`, `config path`, `hook`, help and version.
|
|
@@ -100,7 +111,7 @@ Exit 0 means success (still inspect completeness), 1 means operation/configurati
|
|
|
100
111
|
| `PERMISSION_DENIED` (403) | Check licensing and the operation's privilege; inventory access does not imply attack or connector access. |
|
|
101
112
|
| `NOT_FOUND` | Verify the exact ID and selected profile; a zero-row list is instead a successful search. |
|
|
102
113
|
| `RATE_LIMITED`, `REQUEST_FAILED`, `TRANSPORT_FAILED` | Reads already retry 429/502/503/504 up to twice within budgets; honor `retryAfter` milliseconds and investigate persistent failure. |
|
|
103
|
-
| `RESPONSE_INVALID` | Treat the result as invalid or partial
|
|
114
|
+
| `RESPONSE_INVALID` | Treat the result as invalid or partial. For transport JSON/schema failures, report the HTTP status, contentType, bounded shape and issues (received/expected types); values and validator messages are omitted. Later command checks may carry only a fixed message. |
|
|
104
115
|
| `DEADLINE_EXCEEDED`, `REQUEST_BUDGET_EXCEEDED`, `BYTE_BUDGET_EXCEEDED`, `ROW_BUDGET_EXCEEDED` | Narrow filters/fields or resume a supplied cursor; never infer completeness. |
|
|
105
116
|
| `EXPORT_NOT_READY` | Inspect job state before downloading; status waiting does not guarantee completion. |
|
|
106
117
|
| `OPERATION_BLOCKED`, `OUTCOME_UNKNOWN` | Respect write guards; for unknown mutation outcomes follow the audit ID and read-back advice, never replay blindly. |
|