@knowttl/tenable-axi 0.1.0 → 0.1.1

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 CHANGED
@@ -49,6 +49,7 @@ tenable-axi finding list --profile example --filter 'severity = ["HIGH"]'
49
49
  Configured home reads up to five live exposure cards; unconfigured home stays offline.
50
50
  Only `https://cloud.tenable.com` is supported.
51
51
  Upstream licensing and the user's per-operation permissions still apply.
52
+ HTTP 403 returns `PERMISSION_DENIED` with “Not licensed or not permitted for this key” and advice naming the required privilege where documented.
52
53
  Inventory needs `EXPOSURE_MANAGEMENT.INVENTORY.INVENTORY.READ`; inventory exports need its `EXPORT` privilege and attack exports need `EXPOSURE_MANAGEMENT.ATTACK_PATH.ATTACK_PATH.WRITE`.
53
54
  Connector logs have elevated permissions; their denial does not imply ordinary inventory users need Administrator.
54
55
 
@@ -231,6 +232,7 @@ Use `export asset start` or `export finding start` to preview the filters, prope
231
232
  The selected file profile must configure `writes.allowWrites: true` and allow the exact `inventory-export-assets` or `inventory-export-findings` operation, including for previews.
232
233
  Optional `--body-file` accepts strict documented query/filters JSON, or `-` for stdin, within 1 MiB.
233
234
  Query options use `--properties`, `--use-readable-name true|false`, `--max-chunk-file-size`, `--sort`, `--file-format JSON|CSV` and `--compress true|false`.
235
+ Choose comma-separated `--properties` names from `asset properties` or `finding properties`; `id` maps to `asset_id` or `finding_id` respectively, while other names pass through unchanged.
234
236
  Run again with `--execute --confirm '<exact preview confirmation>'` to create once and return immediately; exports have no server dry run or idempotency guarantee.
235
237
  `TENABLE_AXI_READ_ONLY=true` overrides every configured write policy.
236
238
  `export asset jobs` and `export finding jobs` expose `--status` and `--limit` (default 100, maximum 1000), returning only the last three days without server paging or a claim of complete history.
@@ -251,7 +253,9 @@ Software defaults to name, version, and publisher because the pinned API exposes
251
253
  `doctor` validates local configuration and file security, then performs exactly one tag-properties read without retries.
252
254
  It checks `EXPOSURE_MANAGEMENT.TAG.TAG.READ`, without claiming access to other modules.
253
255
  Collections expose returned count, upstream total when known, completeness and a scoped resume cursor.
254
- Card requests cap each wire page at 25; ordinary lists default to 100 output rows.
256
+ Card lists and home accept upstream pages of up to 25 cards even when fewer are requested, emit only the requested limit, and preserve overflow in a scoped, redacted cursor bounded at 64 KiB.
257
+ Pages above 25 cards or cursors above this bound fail validation rather than dropping cards.
258
+ Ordinary lists default to 100 output rows.
255
259
  `--all` remains subject to invocation budgets and the 10,000-row ceiling.
256
260
  Resume with `--cursor` and the same profile, fields, filters and sort.
257
261
  Offset pagination does not promise snapshot isolation.
@@ -280,6 +284,8 @@ Input files accept `-` for stdin, with only one stdin consumer and a 1 MiB bound
280
284
  State reads, including per-target checks for bulk operations, share invocation budgets; narrow large target sets when those budgets are exhausted.
281
285
  Identical verified updates/creates and already desired assignments return successful no-ops; an unverified missing-resource response remains an error.
282
286
  Deleting a category also deletes its values and assignments; deleting values removes their assignments while retaining the category.
287
+ Value delete and bulk-delete accept unconstrained or undecodable HTTP 2xx replies as exit-0 success once the `SUCCESS` journal outcome is durably recorded.
288
+ An undecodable reply includes a warning, audit ID and status; read back the target before retrying.
283
289
 
284
290
  Use `attack-path list`, `attack-technique list`, and `connector logs` with `--help` for their flags and examples.
285
291
  Attack paths use the published `/api/v1/t1/apa/top-attack-paths/search` route; the pyTenable route disagreement remains a live-acceptance check in the design.
@@ -12,6 +12,9 @@ const cardFields = ["id", "name", "score", "card_type", "is_global_card", "tag_c
12
12
  const detailFields = [...cardFields.filter((field) => !["sla_percentage", "exposure_class"].includes(field)), "ces_scores", "exposures", "exposure_classes_details"];
13
13
  const tagFields = ["id", "category", "value", "name", "product", "asset_count", "weakness_severity_counts", "total_weakness_count", "type", "extra_properties"];
14
14
  const propertyFields = ["property", "operators", "readable_name", "control", "sortable", "filterable", "description"];
15
+ const cursorSchema = z.strictObject({ scope: z.string(), offset: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
16
+ pending: z.array(cardRecord).max(24).optional(), total: z.number().int().nonnegative().optional() });
17
+ const cursorMaxLength = 64 * 1024;
15
18
  const fieldTypes = {
16
19
  id: z.string(), name: z.string(), value: z.string(), category: z.string(), score: z.number(),
17
20
  product: z.string(), type: z.string(), card_type: z.string(), is_global_card: z.boolean(),
@@ -174,9 +177,11 @@ export async function exposureCommand(argv, store, factory = createTransport) {
174
177
  if (flags.has("cursor")) {
175
178
  try {
176
179
  const text = flags.get("cursor");
177
- if (text.length > 1024)
180
+ if (text.length > cursorMaxLength)
181
+ usage("Invalid cursor");
182
+ parsedCursor = cursorSchema.parse(JSON.parse(Buffer.from(text, "base64url").toString("utf8")));
183
+ if (parsedCursor.pending && (name !== "card list" && name !== "home" || parsedCursor.pending.length > parsedCursor.offset))
178
184
  usage("Invalid cursor");
179
- parsedCursor = z.strictObject({ scope: z.string(), offset: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER) }).parse(JSON.parse(Buffer.from(text, "base64url").toString("utf8")));
180
185
  }
181
186
  catch {
182
187
  usage("Cursor does not match this profile, operation, fields or filters");
@@ -262,22 +267,35 @@ export async function exposureCommand(argv, store, factory = createTransport) {
262
267
  }
263
268
  const rows = [];
264
269
  const pages = new Set();
265
- let total, complete = false, reason = "limit", failure;
266
- for (let page = 0; page < 20; page++) {
270
+ let pending = parsedCursor?.pending ?? [];
271
+ let total = parsedCursor?.total, complete = false, reason = "limit", failure;
272
+ const buffered = pending.map((record) => project(record));
273
+ rows.push(...buffered.slice(0, limit));
274
+ pending = pending.slice(rows.length);
275
+ complete = !pending.length && total !== undefined && offset >= total;
276
+ for (let page = 0; page < 20 && !complete && rows.length < limit; page++) {
267
277
  const window = Math.min(name === "tag list" ? 1000 : 25, limit - rows.length);
268
278
  try {
269
279
  const response = (await transport.request(operation, { query: { ...query, limit: window, offset }, ...(body ? { body } : {}) })).body;
270
- if (response.data.length > window)
271
- throw new TransportError({ code: "RESPONSE_INVALID", message: "Tenable returned more rows than requested", operation });
280
+ if (response.data.length > (name === "tag list" ? window : 25))
281
+ throw new TransportError({ code: "RESPONSE_INVALID", message: "Tenable returned more rows than the page bound", operation });
272
282
  const records = response.data.map((record) => project(name === "tag list" ? tagRecord.parse(record) : cardRecord.parse(record)));
273
283
  const pageIdentity = JSON.stringify(response.data.map((record) => record.id));
274
284
  if (records.length && pages.has(pageIdentity))
275
285
  throw new TransportError({ code: "CONTINUATION_REPEATED", message: "Tenable repeated a result page; resume after checking the collection", operation });
276
286
  pages.add(pageIdentity);
277
- rows.push(...records);
287
+ const remainder = response.data.slice(window);
288
+ // Redact before encoding: base64 cursors must not bypass output redaction.
289
+ const nextPending = store.redactor.payload(remainder);
290
+ const nextTotal = response.pagination?.total_record_count ?? response.pagination?.total ?? total;
291
+ const nextCursor = Buffer.from(JSON.stringify({ scope, offset: offset + records.length, pending: nextPending, total: nextTotal })).toString("base64url");
292
+ if (nextCursor.length > cursorMaxLength)
293
+ throw new TransportError({ code: "RESPONSE_INVALID", message: "Card continuation exceeds the cursor byte bound", operation });
294
+ pending = nextPending;
295
+ rows.push(...records.slice(0, window));
278
296
  offset += records.length;
279
- total = response.pagination?.total_record_count ?? response.pagination?.total ?? total;
280
- complete = records.length === 0 || total !== undefined && offset >= total;
297
+ total = nextTotal;
298
+ complete = !pending.length && (records.length === 0 || total !== undefined && offset >= total);
281
299
  if (complete || rows.length >= limit || name === "home")
282
300
  break;
283
301
  reason = "request budget";
@@ -296,7 +314,7 @@ export async function exposureCommand(argv, store, factory = createTransport) {
296
314
  const noun = name === "tag list" ? "tags" : "cards";
297
315
  const suffix = [config ? `--config ${quote(config)}` : "", selected ? `--profile ${quote(selected)}` : ""].filter(Boolean).join(" ");
298
316
  const resumeArgs = argv.slice(start).filter((arg, index, args) => !["--cursor", "--offset"].includes(arg) && !["--cursor", "--offset"].includes(args[index - 1] ?? ""));
299
- const cursor = Buffer.from(JSON.stringify({ scope, offset })).toString("base64url");
317
+ const cursor = Buffer.from(JSON.stringify({ scope, offset, ...(pending.length ? { pending } : {}), ...(total === undefined ? {} : { total }) })).toString("base64url");
300
318
  return { ...(name === "home" ? { ...identity, ...context } : {}), [noun]: rows, count: rows.length, ...(total === undefined ? {} : { total }), complete,
301
319
  ...(!rows.length ? { message: `0 ${noun} matched the selected filters` } : {}),
302
320
  ...(!complete ? { reason, cursor } : {}),
@@ -35,7 +35,8 @@ export const inventoryBindings = Object.freeze(Object.fromEntries(Object.keys(in
35
35
  effect: "read", query: ["offset", "limit", "sort", "extra_properties"], paging: ["offset", "limit"], decoder: inventoryPage }],
36
36
  [`inventory-${kind}-properties-list`, { ...advice, method: "GET", path: `/api/v1/t1/inventory/${noun}/properties`,
37
37
  effect: "read", query: kind === "asset" ? ["asset_classes"] : [],
38
- decoder: kind === "asset" ? z.object({ properties }) : z.object({ data: properties }) }],
38
+ decoder: kind === "asset" ? z.union([z.object({ properties }).transform(({ properties }) => ({ data: properties })),
39
+ z.object({ data: properties })]) : z.object({ data: properties }) }],
39
40
  ];
40
41
  })));
41
42
  const common = { config: "Config path; default credential precedence", profile: "Profile name; default credential precedence",
@@ -37,7 +37,7 @@ const common = { config: "Config path; default platform path", profile: "Profile
37
37
  export const inventoryExportCatalogue = {};
38
38
  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
- flags: { ...common, "body-file": "Optional strict query/filters JSON file, '-' for stdin; maximum 1 MiB", properties: "Comma-separated property names", "use-readable-name": "true|false; API default true",
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
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
43
  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>`] };
@@ -91,6 +91,8 @@ export async function inventoryExportCommand(argv, store, factory = createTransp
91
91
  usage("Invalid chunk size");
92
92
  value = Number(raw);
93
93
  }
94
+ if (key === "properties")
95
+ value = raw.split(",").map((property) => property === "id" ? `${argv[1]}_id` : property).join(",");
94
96
  return [[key.replaceAll("-", "_"), value]];
95
97
  }));
96
98
  const input = exportInput.safeParse({ ...(body === undefined ? {} : { body }), query });
@@ -206,7 +206,7 @@ export async function inventoryCommand(argv, store, transportFactory = createTra
206
206
  let data;
207
207
  let exhausted;
208
208
  if (verb === "properties") {
209
- data = response.body[kind === "asset" ? "properties" : "data"];
209
+ data = response.body.data;
210
210
  exhausted = true;
211
211
  }
212
212
  else {
@@ -41,8 +41,8 @@ const definitions = [
41
41
  ["tags-list-tag-values", "GET", "/tags/values", "read", ["f", "ft", "wf", "w", "limit", "offset", "sort"], list("values"), "Basic [16]"],
42
42
  ["tags-tag-value-details", "GET", "/tags/values/{tag_value_uuid}", "read", [], detail, "Basic [16]"],
43
43
  ["tags-update-tag-value", "PUT", "/tags/values/{tag_value_uuid}", "write", [], detail, "Scan Operator [24] or PS.ACCT_MGMT.TAGS.EDIT"],
44
- ["tags-delete-tag-value", "DELETE", "/tags/values/{tag_value_uuid}", "write", [], record, "Scan Operator [24] or PS.ACCT_MGMT.TAGS.DELETE; edit permission on the value"],
45
- ["tags-delete-tag-values-bulk", "POST", "/tags/values/delete-requests", "write", [], record, "Scan Operator [24] or PS.ACCT_MGMT.TAGS.DELETE"],
44
+ ["tags-delete-tag-value", "DELETE", "/tags/values/{tag_value_uuid}", "write", [], z.unknown(), "Scan Operator [24] or PS.ACCT_MGMT.TAGS.DELETE; edit permission on the value"],
45
+ ["tags-delete-tag-values-bulk", "POST", "/tags/values/delete-requests", "write", [], z.unknown(), "Scan Operator [24] or PS.ACCT_MGMT.TAGS.DELETE"],
46
46
  ["tags-assign-asset-tags", "POST", "/tags/assets/assignments", "write", [], z.object({ job_uuid: z.string().min(1) }), "Basic [16]"],
47
47
  ["tags-list-asset-tags", "GET", "/tags/assets/{asset_uuid}/assignments", "read", [], z.object({ tags: z.array(z.object({ asset_uuid: uuid, value_uuid: uuid }).passthrough()) }), "Basic [16] or PS.ACCT_MGMT.TAGS.READ"],
48
48
  ["tags-list-exclusions", "GET", "/tags/values/{tag_value_uuid}/exclusions", "read", ["target_type", "limit", "offset"], list("excluded_targets"), "Basic [16] or PS.ACCT_MGMT.TAGS.READ"],
@@ -126,7 +126,17 @@ export async function platformTagCommand(argv, store, factory = createTransport,
126
126
  const input = platformTagInputs[operation].safeParse({ ...(get("id") ? { id: get("id") } : {}), ...(body === undefined ? {} : { body }) });
127
127
  if (!input.success)
128
128
  usage("Invalid tag input; use documented fields and UUID arrays, at most 40 dynamic rules and 1024 values per rule; security fields are forbidden");
129
- const result = await writeFactory({ config: get("config"), profile: get("profile") }).run(operation, input.data, { execute: !!get("execute"), dryRun: !!get("dry-run"), confirm: get("confirm"), intentId: get("intent-id") });
129
+ const readBack = "The write succeeded; read back the target before retrying";
130
+ const result = await writeFactory({ config: get("config"), profile: get("profile") }).run(operation, input.data, { execute: !!get("execute"), dryRun: !!get("dry-run"), confirm: get("confirm"), intentId: get("intent-id") }).catch((error) => {
131
+ if (!value || !["delete", "bulk-delete"].includes(verb)
132
+ || !(error instanceof TransportError) || error.error.code !== "RESPONSE_INVALID" || !error.error.auditId
133
+ || error.error.status === undefined || error.error.status < 200 || error.error.status >= 300)
134
+ throw error;
135
+ return { kind: "success", auditId: error.error.auditId, status: error.error.status,
136
+ warning: "Write succeeded, but its response could not be decoded", help: [readBack] };
137
+ });
138
+ if ("warning" in result)
139
+ return result;
130
140
  if (result.kind !== "success") {
131
141
  const output = preview(result);
132
142
  return { ...output, ...(truncated ? { help: [`Run ${command(["--full"])} --full to read complete text`] } : {}) };
@@ -224,7 +224,7 @@ export function constructTransport(options, dependencies) {
224
224
  const hint = status === 401 ? "Check both SecretRefs and run tenable-axi auth status"
225
225
  : status === 403 ? record.permissionHelp : status === 404 ? "Check the resource identifier and operation scope"
226
226
  : status === 429 ? "Retry after the reported delay; narrow reads to reduce requests" : record.validationHelp;
227
- const message = errorMessage(text) ?? `Tenable returned HTTP ${status}`;
227
+ const message = status === 403 ? "Not licensed or not permitted for this key" : errorMessage(text) ?? `Tenable returned HTTP ${status}`;
228
228
  fail(code, redact(message), operation, [hint], { status,
229
229
  ...(lastRetryAfter === undefined ? {} : { retryAfter: lastRetryAfter }) });
230
230
  }
package/docs/commands.md CHANGED
@@ -429,7 +429,7 @@ Operation: `inventory-export-assets`.
429
429
  | `--full` | Full output; default false |
430
430
  | `--help` | Show help |
431
431
  | `--body-file` | Optional strict query/filters JSON file, '-' for stdin; maximum 1 MiB |
432
- | `--properties` | Comma-separated property names |
432
+ | `--properties` | Comma-separated names from asset properties; id maps to asset_id |
433
433
  | `--use-readable-name` | true\|false; API default true |
434
434
  | `--max-chunk-file-size` | 5242880-104857600 bytes; API default 20971520 |
435
435
  | `--sort` | property:asc\|desc |
@@ -568,7 +568,7 @@ Operation: `inventory-export-findings`.
568
568
  | `--full` | Full output; default false |
569
569
  | `--help` | Show help |
570
570
  | `--body-file` | Optional strict query/filters JSON file, '-' for stdin; maximum 1 MiB |
571
- | `--properties` | Comma-separated property names |
571
+ | `--properties` | Comma-separated names from finding properties; id maps to finding_id |
572
572
  | `--use-readable-name` | true\|false; API default true |
573
573
  | `--max-chunk-file-size` | 5242880-104857600 bytes; API default 20971520 |
574
574
  | `--sort` | property:asc\|desc |
package/package.json CHANGED
@@ -1,15 +1,36 @@
1
1
  {
2
2
  "name": "@knowttl/tenable-axi",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Investigate Tenable One exposure and run explicitly guarded writes",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "bin": { "tenable-axi": "bin/tenable-axi.js", "tenable-axi-hook": "bin/tenable-axi-hook.js" },
8
- "exports": { "./catalogue": "./dist/src/catalogue.js", "./inventory": "./inventory/capabilities.json", "./axi-credential.schema.json": "./axi-credential.schema.json" },
9
- "files": ["bin", "dist/src", "inventory/capabilities.json", "axi-credential.schema.json", "docs/commands.md", "skills"],
10
- "publishConfig": { "access": "public" },
11
- "repository": { "type": "git", "url": "git+https://github.com/knowttl/tenable-axi.git" },
12
- "engines": { "node": ">=22.12.0" },
7
+ "bin": {
8
+ "tenable-axi": "bin/tenable-axi.js",
9
+ "tenable-axi-hook": "bin/tenable-axi-hook.js"
10
+ },
11
+ "exports": {
12
+ "./catalogue": "./dist/src/catalogue.js",
13
+ "./inventory": "./inventory/capabilities.json",
14
+ "./axi-credential.schema.json": "./axi-credential.schema.json"
15
+ },
16
+ "files": [
17
+ "bin",
18
+ "dist/src",
19
+ "inventory/capabilities.json",
20
+ "axi-credential.schema.json",
21
+ "docs/commands.md",
22
+ "skills"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/knowttl/tenable-axi.git"
30
+ },
31
+ "engines": {
32
+ "node": ">=22.12.0"
33
+ },
13
34
  "packageManager": "pnpm@10.34.6",
14
35
  "scripts": {
15
36
  "build": "tsc -p tsconfig.json",
@@ -21,6 +42,16 @@
21
42
  "spec:generate": "node scripts/specs.mjs --generate",
22
43
  "spec:check": "node scripts/specs.mjs --check"
23
44
  },
24
- "dependencies": { "@toon-format/toon": "2.3.1", "axi-sdk-js": "0.1.13", "zod": "4.3.6", "smol-toml": "1.9.1" },
25
- "devDependencies": { "@types/node": "22.20.5", "typescript": "5.9.3", "vitest": "5.0.2", "openapi-typescript": "7.13.0" }
45
+ "dependencies": {
46
+ "@toon-format/toon": "2.3.1",
47
+ "axi-sdk-js": "0.1.13",
48
+ "zod": "4.3.6",
49
+ "smol-toml": "1.9.1"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "22.20.5",
53
+ "typescript": "5.9.3",
54
+ "vitest": "5.0.2",
55
+ "openapi-typescript": "7.13.0"
56
+ }
26
57
  }