@knowttl/tenable-axi 0.1.7 → 0.1.9

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
@@ -11,7 +11,8 @@ Investigate Tenable One exposure and run explicitly guarded writes
11
11
  Tenable One spans inventory, attack paths and business workflows with different routes and permissions.
12
12
  Agents and the humans running them need bounded evidence instead of large responses and guessed API calls.
13
13
  tenable-axi exposes reviewed commands, validates responses and returns compact TOON with next-step hints.
14
- Reads stay bounded, and writes require explicit scope, a preview and exact confirmation.
14
+ Reads stay bounded, and named writes require explicit scope, a preview and exact confirmation.
15
+ `raw write` sends API mutations immediately.
15
16
 
16
17
  ## Quickstart
17
18
 
@@ -47,7 +48,8 @@ tenable-axi setup hooks
47
48
  npx skills add knowttl/tenable-axi --skill tenable-axi
48
49
  ```
49
50
 
50
- Hooks inject local profile, origin and write posture at session start; the skill supplies command discovery on demand.
51
+ Hooks inject local profile, origin and the `readOnly` field for named-command write posture at session start.
52
+ The skill supplies command discovery on demand.
51
53
  Both are optional, grant no permissions and work independently.
52
54
  Restart the agent session after installing hooks.
53
55
  The [compact agent guide](https://github.com/knowttl/tenable-axi/blob/main/skills/tenable-axi/SKILL.md) supplies investigation examples, output bounds, read allowlists and failure notes so agents can start without running help.
@@ -71,20 +73,21 @@ The [generated command reference](https://github.com/knowttl/tenable-axi/blob/ma
71
73
  | `tag category/value/assignment/exclusion/asset-filter` | Inspect and manage platform tags | Read/write | [Platform tags](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#platform-tags) |
72
74
  | `initiative`, `combination` | Manage Exposure Response workflows | Read/write | [Exposure Response](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#exposure-response) |
73
75
  | `export` | Create jobs, check status and download results | Read/write | [Exports](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#inventory-exports) |
74
- | `raw` | Read API paths and send guarded writes | Read/write | [Raw API](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#raw-api) |
76
+ | `raw` | Read API paths and send writes directly | Read/write | [Raw API](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#raw-api) |
75
77
  | `auth`, `profile`, `config`, `doctor` | Inspect setup and module access | Local/read | [Doctor](https://github.com/knowttl/tenable-axi/blob/main/docs/commands.md#doctor) |
76
78
  | `setup hooks`, `hook` | Install integrations and read local context | Local | [Integration](https://github.com/knowttl/tenable-axi/blob/main/docs/agent-integration.md) |
77
79
 
78
80
  ## Safety
79
81
 
80
- Writes are read-only by default.
82
+ Named write commands are read-only by default.
81
83
  A file profile must enable `writes.allowWrites` and allow each exact operation ID in `writes.operations`, including for previews.
82
- Preview first, then pass `--execute --confirm '<exact preview confirmation>'` to send once.
83
- `TENABLE_AXI_READ_ONLY=true` forces read-only even when the profile allows writes.
84
+ For named writes, preview first, then pass `--execute --confirm '<exact preview confirmation>'` to send once.
85
+ Review the [raw write controls](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#raw-api) before sending a passthrough request.
84
86
  There is no `TENABLE_AXI_ALLOW_*` environment gate; configured operation allowlists control scope.
85
- A durable redacted journal records intent before sending; reconcile unknown outcomes before retrying.
87
+ A durable redacted journal records named-command intent before sending.
88
+ On `OUTCOME_UNKNOWN`, read the target back before sending again and never replay the original request.
86
89
  Credentials use environment/file SecretRefs, never inline secrets or arguments.
87
- Credential minting, users, roles and access-control administration stay blocked; raw HTTP is limited to validated paths on the exact origin.
90
+ Credential minting, users, roles and access-control administration stay blocked, including through `raw`; raw HTTP is limited to validated paths on the exact origin.
88
91
  See [write safety](https://github.com/knowttl/tenable-axi/blob/main/docs/safety.md) and the [permission ledger](https://github.com/knowttl/tenable-axi/blob/main/docs/design.md#complete-operation-ledger).
89
92
 
90
93
  ## Configuration
@@ -99,8 +102,9 @@ See [write safety](https://github.com/knowttl/tenable-axi/blob/main/docs/safety.
99
102
  | `TENABLE_AXI_PROFILE` | Named profile, overridden by `--profile` | Environment profile, configured default, or sole profile |
100
103
  | `TENABLE_AXI_ACCESS_KEY`, `TENABLE_AXI_SECRET_KEY` | Complete environment credential pair | Unset |
101
104
  | `TENABLE_AXI_ORIGIN` | Environment profile origin; only the exact commercial origin is valid | `https://cloud.tenable.com` |
102
- | `TENABLE_AXI_READ_ONLY` | Force read-only with `1` or `true` | Unset; profile policy applies |
103
- | `TENABLE_AXI_WRITE_LOG` | Private journal path | State directory's `writes.log` |
105
+ | `TENABLE_AXI_READ_ONLY` | [Read-only override](https://github.com/knowttl/tenable-axi/blob/main/docs/configuration.md#selection-and-environment) for named and raw writes | Unset |
106
+ | `TENABLE_AXI_WRITE_LOG` | Private journal path for named writes | State directory's `writes.log` |
107
+ | `TENABLE_AXI_CREDENTIAL_REVISION` | Host credential binding as `<credential-id>:<revision>` for named write confirmations | Unset |
104
108
  | `XDG_CONFIG_HOME`, `XDG_STATE_HOME` | Absolute Unix config/state bases | `~/.config`, `~/.local/state` |
105
109
  | `APPDATA`, `LOCALAPPDATA` | Absolute Windows config/state bases | `~/AppData/Roaming`, `~/AppData/Local` |
106
110
  | `CLAUDE_CONFIG_DIR`, `CODEX_HOME` | Hook configuration directories | `~/.claude`, `~/.codex` |
@@ -132,7 +136,8 @@ See [behavior](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md
132
136
  | `PERMISSION_DENIED` / HTTP 403 | Check licensing and the operation's privilege; run `doctor` for module-level advice. |
133
137
  | `CONFIG_INVALID` with environment credentials | Set both keys and use only the supported origin; partial environment profiles fail closed. |
134
138
  | `CONFIG_INSECURE` | Use an owned regular file with mode 600 on Unix or a protected Windows DACL. |
135
- | Writes refused | Check the file profile's operation allowlist and forced read-only setting. |
139
+ | Named writes refused | Check the file profile's operation allowlist and forced read-only setting. |
140
+ | Raw writes refused | Check the [profile, override, path and body requirements](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md#raw-api). |
136
141
  | Cursor rejected after collection changes | Restart without the cursor and retain the original selectors. |
137
142
 
138
143
  ## Contributing
@@ -110,7 +110,7 @@ export declare const catalogue: {
110
110
  readonly examples: readonly ["tenable-axi raw get --path /api/v1/t1/tags/properties", "tenable-axi raw get --path /api/v1/t1/tags/search --query limit=5"];
111
111
  };
112
112
  readonly "raw write": {
113
- readonly description: "Send one raw write when the profile allows writes and the operation list includes raw-write";
113
+ readonly description: "Send one raw write to any validated Tenable API path with the selected file profile keys";
114
114
  readonly flags: {
115
115
  readonly config: "Config path; default platform path";
116
116
  readonly profile: "Profile name; default credential precedence";
@@ -118,13 +118,9 @@ export declare const catalogue: {
118
118
  readonly path: "Required absolute API path such as /api/v1/...";
119
119
  readonly query: "URL query such as key=value";
120
120
  readonly "body-file": "JSON body file or - for stdin";
121
- readonly execute: "Send after exact confirmation; default preview only";
122
- readonly "dry-run": "Preview only; incompatible with --execute";
123
- readonly confirm: "Exact preview confirmation";
124
- readonly "intent-id": "Optional durable intent identifier";
125
121
  readonly help: "Show help; default false";
126
122
  };
127
- readonly examples: readonly ["tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json", "tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json --execute --confirm <preview confirm>"];
123
+ readonly examples: readonly ["tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json", "tenable-axi raw write --method DELETE --path /api/v1/example"];
128
124
  };
129
125
  readonly "setup hooks": {
130
126
  readonly description: "Explicitly install or repair local agent session integrations";
@@ -25,9 +25,9 @@ export const catalogue = {
25
25
  examples: ["tenable-axi raw get --path /api/v1/t1/tags/properties", "tenable-axi raw get --path /api/v1/t1/tags/search --query limit=5"],
26
26
  },
27
27
  "raw write": {
28
- description: "Send one raw write when the profile allows writes and the operation list includes raw-write",
29
- flags: { config: "Config path; default platform path", profile: "Profile name; default credential precedence", method: "Required POST, PUT, PATCH or DELETE", path: "Required absolute API path such as /api/v1/...", query: "URL query such as key=value", "body-file": "JSON body file or - for stdin", execute: "Send after exact confirmation; default preview only", "dry-run": "Preview only; incompatible with --execute", confirm: "Exact preview confirmation", "intent-id": "Optional durable intent identifier", help: "Show help; default false" },
30
- examples: ["tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json", "tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json --execute --confirm <preview confirm>"],
28
+ description: "Send one raw write to any validated Tenable API path with the selected file profile keys",
29
+ flags: { config: "Config path; default platform path", profile: "Profile name; default credential precedence", method: "Required POST, PUT, PATCH or DELETE", path: "Required absolute API path such as /api/v1/...", query: "URL query such as key=value", "body-file": "JSON body file or - for stdin", help: "Show help; default false" },
30
+ examples: ["tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json", "tenable-axi raw write --method DELETE --path /api/v1/example"],
31
31
  },
32
32
  "setup hooks": {
33
33
  description: "Explicitly install or repair local agent session integrations",
package/dist/src/cli.js CHANGED
@@ -42,7 +42,7 @@ export async function main(argv = process.argv.slice(2), options = {}) {
42
42
  if (argv[0] === "tag" && !["list", "properties"].includes(argv[1] ?? ""))
43
43
  return store.redactor.payload(await platformTagCommand(argv, store, options.transportFactory, options.writeCoordinatorFactory ?? ((flags) => createWriteCoordinator(flags, options.credentials))));
44
44
  if (argv[0] === "raw")
45
- return store.redactor.payload(await rawCommand(argv, store, options.transportFactory, options.writeCoordinatorFactory ?? ((flags) => createWriteCoordinator(flags, options.credentials)), (chunk, contentType, signal) => {
45
+ return store.redactor.payload(await rawCommand(argv, store, options.transportFactory, (chunk, contentType, signal) => {
46
46
  if (!rawStream)
47
47
  (options.stderr ?? process.stderr).write(`Content-Type: ${contentType ?? "application/octet-stream"}\n`);
48
48
  rawStream = true;
@@ -36,6 +36,10 @@ export declare function credentialStore(options?: CredentialContext, redactor?:
36
36
  configPath: (explicit?: string) => string;
37
37
  statePath: () => string;
38
38
  readOnly: () => boolean;
39
+ credentialBinding: () => {
40
+ id: string;
41
+ revision: number;
42
+ } | undefined;
39
43
  load: (explicit?: string, verifyAcl?: boolean) => {
40
44
  path: string;
41
45
  config: {
@@ -50,6 +50,15 @@ export function credentialStore(options = {}, redactor = new SecretRedactor()) {
50
50
  return true;
51
51
  return invalid("Read-only override must be 1, true, 0 or false");
52
52
  }
53
+ function credentialBinding() {
54
+ const value = env.TENABLE_AXI_CREDENTIAL_REVISION;
55
+ if (value === undefined)
56
+ return undefined;
57
+ const match = /^([^:\s]{1,128}):([1-9][0-9]{0,14})$/.exec(value);
58
+ if (!match)
59
+ return invalid("Credential revision must be <credential-id>:<revision> with a positive integer revision");
60
+ return { id: match[1], revision: Number(match[2]) };
61
+ }
53
62
  function load(explicit, verifyAcl = false) {
54
63
  const path = configPath(explicit);
55
64
  let raw;
@@ -144,5 +153,5 @@ export function credentialStore(options = {}, redactor = new SecretRedactor()) {
144
153
  return { profiles: Object.entries(loaded.config.profiles).map(([name, profile]) => ({ name, origin: profile.origin, default: name === loaded.config.defaultProfile })),
145
154
  count: Object.keys(loaded.config.profiles).length, config: loaded.path };
146
155
  }
147
- return { configPath, statePath: () => toolDirectory("state", env, platform, home), readOnly, load, select, credentials, status, list, redactor };
156
+ return { configPath, statePath: () => toolDirectory("state", env, platform, home), readOnly, credentialBinding, load, select, credentials, status, list, redactor };
148
157
  }
package/dist/src/raw.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import type { TransportFactory } from "./exposure.js";
2
- import { type WriteCoordinatorFactory } from "./inventory-export.js";
3
2
  import type { credentialStore } from "./profiles.js";
4
- export declare function rawCommand(argv: string[], store: ReturnType<typeof credentialStore>, factory?: TransportFactory, writeFactory?: WriteCoordinatorFactory, output?: (chunk: Uint8Array, contentType: string | null, signal: AbortSignal) => void | Promise<void>): Promise<Record<string, unknown>>;
3
+ export declare function rawCommand(argv: string[], store: ReturnType<typeof credentialStore>, factory?: TransportFactory, output?: (chunk: Uint8Array, contentType: string | null, signal: AbortSignal) => void | Promise<void>): Promise<Record<string, unknown>>;
package/dist/src/raw.js CHANGED
@@ -4,14 +4,14 @@ import { z } from "zod";
4
4
  import { catalogue } from "./catalogue.js";
5
5
  import { bodyFile } from "./inventory-export.js";
6
6
  import { createTransport } from "./transport.js";
7
- import { createWriteCoordinator } from "./writes.js";
7
+ import { securityPayload } from "./writes-core.js";
8
8
  const accessControlRoute = /(?:^|\/)(?:users?|(?:access-)?groups?|roles?|permissions?|access-control|credentials?|share|(?:[a-z0-9._~]+-)*keys?|apikeys?)(?:\/|$)/i;
9
9
  const apiPath = z.string()
10
10
  .regex(/^\/[A-Za-z0-9._~/-]+$/)
11
11
  .refine((path) => !/(?:^|\/)\.{1,2}(?:\/|$)|\/\//.test(path))
12
12
  .refine((path) => !accessControlRoute.test(path));
13
13
  const writeMethod = z.enum(["POST", "PUT", "PATCH", "DELETE"]);
14
- export async function rawCommand(argv, store, factory = createTransport, writeFactory = createWriteCoordinator, output = () => { }) {
14
+ export async function rawCommand(argv, store, factory = createTransport, output = () => { }) {
15
15
  const name = argv.slice(0, 2).join(" ");
16
16
  const entry = catalogue[name];
17
17
  const usage = (message) => {
@@ -26,7 +26,7 @@ export async function rawCommand(argv, store, factory = createTransport, writeFa
26
26
  const flag = argv[index];
27
27
  if (!flag.startsWith("--") || !Object.hasOwn(entry.flags, flag.slice(2)) || flags.has(flag))
28
28
  usage(`Unknown argument, flag, or duplicate flag: ${flag}`);
29
- const value = ["--help", "--execute", "--dry-run"].includes(flag) ? "true" : argv[++index];
29
+ const value = flag === "--help" ? "true" : argv[++index];
30
30
  if (!value || value.startsWith("--"))
31
31
  usage(`Missing value for ${flag}`);
32
32
  flags.set(flag, value);
@@ -75,11 +75,17 @@ export async function rawCommand(argv, store, factory = createTransport, writeFa
75
75
  usage("Cannot read --body-file as JSON within the 1 MiB limit");
76
76
  }
77
77
  }
78
- const result = await writeFactory({ config: get("config"), profile: get("profile") }).run("raw-write", { query, body }, { execute: get("execute") === "true", dryRun: get("dry-run") === "true", confirm: get("confirm"), intentId: get("intent-id") }, { method, path }, async (contentType, signal) => {
79
- await output(new Uint8Array(), contentType, signal);
80
- return (chunk) => output(chunk, contentType, signal);
81
- });
82
- if (result.kind !== "success")
83
- return result;
78
+ if (securityPayload(body))
79
+ usage("Security administration payloads such as acl, permissions, roles, credentials or api_keys are blocked");
80
+ if (store.readOnly())
81
+ throw new AxiError("Writes are disabled by TENABLE_AXI_READ_ONLY", "WRITES_DISABLED", ["raw get still reads while the operator keeps TENABLE_AXI_READ_ONLY set"]);
82
+ const profile = store.select(store.load(get("config")).config, get("profile"));
83
+ if (profile.source === "env-profile")
84
+ throw new AxiError("Environment profiles cannot send writes", "WRITES_DISABLED", ["Select a file profile with --profile; run tenable-axi config path"]);
85
+ await factory({ keys: store.credentials(profile), origin: profile.origin }).request("raw-write", { raw: { method, path }, query, body,
86
+ rawOutput: async (contentType, signal) => {
87
+ await output(new Uint8Array(), contentType, signal);
88
+ return (chunk) => output(chunk, contentType, signal);
89
+ } });
84
90
  return {};
85
91
  }
@@ -18,6 +18,7 @@ export function constructTransport(options, dependencies) {
18
18
  const fail = (code, message, operation = "transport", help = [], details = {}) => {
19
19
  throw new TransportError({ code, message, operation, ...details }, help);
20
20
  };
21
+ const unknownOutcome = (operation) => fail("OUTCOME_UNKNOWN", "Mutation outcome is unknown", operation, ["Read the target back before sending again; never replay"]);
21
22
  if ((options.origin ?? TENABLE_ORIGIN) !== TENABLE_ORIGIN) {
22
23
  fail("CONFIG_INVALID", "Origin must be exactly https://cloud.tenable.com");
23
24
  }
@@ -115,7 +116,7 @@ export function constructTransport(options, dependencies) {
115
116
  if (input.continuation !== undefined && seen.has(identity)) {
116
117
  fail("CONTINUATION_REPEATED", "The server repeated a continuation", operation);
117
118
  }
118
- if (record.effect === "write" && !dependencies.consumeWriteAuthorization?.(input.authorization, { operation, method: record.method, url, body })) {
119
+ if (record.effect === "write" && !input.raw && !dependencies.consumeWriteAuthorization?.(input.authorization, { operation, method: record.method, url, body })) {
119
120
  fail("OPERATION_BLOCKED", "Writes require coordinator authorization", operation);
120
121
  }
121
122
  seen.add(identity);
@@ -200,21 +201,28 @@ export function constructTransport(options, dependencies) {
200
201
  text = record.responseMode === "file" && downloading ? "" : contents.toString("utf8");
201
202
  }
202
203
  catch (error) {
204
+ if (record.effect === "write" && !(error instanceof TransportError && error.error.status !== undefined)) {
205
+ unknownOutcome(operation);
206
+ }
203
207
  if (error instanceof TransportError)
204
208
  throw error;
205
- const code = record.effect === "write" ? "OUTCOME_UNKNOWN"
206
- : input.signal?.aborted ? "REQUEST_CANCELLED" : timedOut ? "DEADLINE_EXCEEDED" : "TRANSPORT_FAILED";
207
- fail(code, record.effect === "write" ? "Mutation outcome is unknown; read back before retrying"
208
- : "Tenable request could not complete", operation, ["Check connectivity and retry the read when ready"]);
209
+ const code = input.signal?.aborted ? "REQUEST_CANCELLED" : timedOut ? "DEADLINE_EXCEEDED" : "TRANSPORT_FAILED";
210
+ fail(code, "Tenable request could not complete", operation, ["Check connectivity and retry the read when ready"]);
209
211
  }
210
212
  finally {
211
213
  clearTimeout(timer);
212
214
  input.signal?.removeEventListener("abort", abort);
213
215
  }
214
- if (input.signal?.aborted)
215
- fail(record.effect === "write" ? "OUTCOME_UNKNOWN" : "REQUEST_CANCELLED", "Request was cancelled", operation);
216
- if (now() >= deadline)
217
- fail(record.effect === "write" ? "OUTCOME_UNKNOWN" : "DEADLINE_EXCEEDED", "Invocation deadline exceeded", operation);
216
+ if (input.signal?.aborted) {
217
+ if (record.effect === "write")
218
+ unknownOutcome(operation);
219
+ fail("REQUEST_CANCELLED", "Request was cancelled", operation);
220
+ }
221
+ if (now() >= deadline) {
222
+ if (record.effect === "write")
223
+ unknownOutcome(operation);
224
+ fail("DEADLINE_EXCEEDED", "Invocation deadline exceeded", operation);
225
+ }
218
226
  if (response.status >= 200 && response.status < 300) {
219
227
  const contentType = response.headers.get("content-type");
220
228
  if (input.raw)
@@ -37,6 +37,10 @@ export type MutationPreview = Readonly<{
37
37
  proposed: unknown;
38
38
  confirm: string;
39
39
  noop: boolean;
40
+ credential?: Readonly<{
41
+ id: string;
42
+ revision: number;
43
+ }>;
40
44
  }>;
41
45
  export type WriteCoordinatorOptions = {
42
46
  config?: string;
@@ -50,10 +54,7 @@ export type MutationOptions = {
50
54
  confirm?: string;
51
55
  intentId?: string;
52
56
  };
53
- export type RawWriteRoute = Readonly<{
54
- method: "POST" | "PUT" | "PATCH" | "DELETE";
55
- path: string;
56
- }>;
57
+ export declare function securityPayload(value: unknown): boolean;
57
58
  export declare function constructWriteCoordinator(options: WriteCoordinatorOptions, dependencies: {
58
59
  operations: Readonly<Record<string, MutationOperation>>;
59
60
  bindings: Readonly<Record<string, OperationBinding>>;
@@ -67,7 +68,7 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
67
68
  allowWrites: boolean;
68
69
  operations: readonly string[];
69
70
  }>;
70
- run: (operation: string, input: unknown, flags?: MutationOptions, raw?: RawWriteRoute, rawOutput?: RequestOptions["rawOutput"]) => Promise<{
71
+ run: (operation: string, input: unknown, flags?: MutationOptions) => Promise<{
71
72
  kind: "dry-run";
72
73
  preview: Readonly<{
73
74
  profile: string;
@@ -78,11 +79,14 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
78
79
  proposed: unknown;
79
80
  confirm: string;
80
81
  noop: boolean;
82
+ credential?: Readonly<{
83
+ id: string;
84
+ revision: number;
85
+ }>;
81
86
  }>;
82
87
  auditId?: undefined;
83
88
  status?: undefined;
84
89
  response?: undefined;
85
- contentType?: undefined;
86
90
  } | {
87
91
  kind: "noop";
88
92
  preview: Readonly<{
@@ -94,11 +98,14 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
94
98
  proposed: unknown;
95
99
  confirm: string;
96
100
  noop: boolean;
101
+ credential?: Readonly<{
102
+ id: string;
103
+ revision: number;
104
+ }>;
97
105
  }>;
98
106
  auditId?: undefined;
99
107
  status?: undefined;
100
108
  response?: undefined;
101
- contentType?: undefined;
102
109
  } | {
103
110
  kind: "success";
104
111
  preview: Readonly<{
@@ -110,11 +117,14 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
110
117
  proposed: unknown;
111
118
  confirm: string;
112
119
  noop: boolean;
120
+ credential?: Readonly<{
121
+ id: string;
122
+ revision: number;
123
+ }>;
113
124
  }>;
114
125
  auditId: `${string}-${string}-${string}-${string}-${string}`;
115
126
  status: number;
116
127
  response: unknown;
117
- contentType: string | null | undefined;
118
128
  }>;
119
129
  reader: {
120
130
  request: (name: string, options?: RequestOptions) => Promise<{
@@ -5,13 +5,8 @@ import { z } from "zod";
5
5
  import { credentialStore } from "./profiles.js";
6
6
  import { privateFiles } from "./private-file.js";
7
7
  import { constructTransport, TransportError } from "./transport-core.js";
8
- function rawWriteDefinition(route) {
9
- return {
10
- input: z.strictObject({ query: z.record(z.string(), z.union([z.string(), z.array(z.string())])).optional(), body: z.unknown().optional() }),
11
- prepare: (input) => ({ target: { kind: `${route.method} ${route.path}`, payload: true }, request: input }),
12
- effect: `Send ${route.method} ${route.path}`,
13
- readBackHelp: ["Read the target through its owning Tenable API before any new intent; never replay this intent"],
14
- };
8
+ export function securityPayload(value) {
9
+ return !!value && typeof value === "object" && Object.entries(value).some(([key, child]) => /^(?:acl|access_control|permissions?|roles|credentials|api_keys)$/i.test(key) || securityPayload(child));
15
10
  }
16
11
  function canonical(value) {
17
12
  const normalize = (value) => {
@@ -44,6 +39,7 @@ export function constructWriteCoordinator(options, dependencies) {
44
39
  const store = credentialStore(dependencies.credentials);
45
40
  const profile = store.select(store.load(options.config).config, options.profile);
46
41
  const forced = store.readOnly() || options.readOnly === true;
42
+ const credential = store.credentialBinding();
47
43
  const scope = Object.freeze({ profile: profile.name, origin: profile.origin,
48
44
  allowWrites: profile.source !== "env-profile" && profile.writes.allowWrites,
49
45
  operations: Object.freeze([...profile.writes.operations]) });
@@ -137,10 +133,10 @@ export function constructWriteCoordinator(options, dependencies) {
137
133
  }
138
134
  }
139
135
  }
140
- async function run(operation, input, flags = {}, raw, rawOutput) {
136
+ async function run(operation, input, flags = {}) {
141
137
  flags = { ...flags };
142
- const definition = raw ? rawWriteDefinition(raw) : Object.hasOwn(definitions, operation) ? definitions[operation] : undefined;
143
- if (!definition || (!raw && bindings[operation]?.effect !== "write"))
138
+ const definition = Object.hasOwn(definitions, operation) ? definitions[operation] : undefined;
139
+ if (!definition || bindings[operation]?.effect !== "write")
144
140
  fail("OPERATION_BLOCKED", "Operation has no reviewed write binding", operation);
145
141
  const parsed = definition.input.safeParse(input);
146
142
  if (!parsed.success)
@@ -148,8 +144,7 @@ export function constructWriteCoordinator(options, dependencies) {
148
144
  const prepared = definition.prepare(JSON.parse(canonical(parsed.data)));
149
145
  const request = JSON.parse(canonical(prepared.request));
150
146
  const target = JSON.parse(canonical(prepared.target));
151
- const securityField = (value) => !!value && typeof value === "object" && Object.entries(value).some(([key, child]) => /^(?:acl|access_control|permissions?|roles|credentials|api_keys)$/i.test(key) || securityField(child));
152
- if (securityField(request.body))
147
+ if (securityPayload(request.body))
153
148
  fail("VALIDATION_ERROR", "Security administration payloads are blocked", operation);
154
149
  const uuid = z.string().uuid();
155
150
  if (!target.kind?.trim() || ("id" in target ? !uuid.safeParse(target.id).success
@@ -165,14 +160,20 @@ export function constructWriteCoordinator(options, dependencies) {
165
160
  if (!scope.operations.includes(operation))
166
161
  fail("OPERATION_NOT_WRITABLE", "Operation is outside the configured write scope", operation);
167
162
  const connection = sender();
168
- const plan = connection.prepare(operation, { ...request, raw });
163
+ const plan = connection.prepare(operation, request);
169
164
  const { effect: _effect, ...identity } = plan;
170
165
  const confirmationTarget = "payload" in target ? { kind: target.kind, digest: digest(canonical(request)) } : target;
171
- const confirm = canonical([scope.profile, operation, confirmationTarget]);
166
+ const unbound = canonical([scope.profile, operation, confirmationTarget]);
167
+ const confirm = credential ? canonical([scope.profile, operation, confirmationTarget,
168
+ `credential:${digest(`${credential.id}:${credential.revision}`)}`]) : unbound;
169
+ if (flags.execute && flags.confirm !== confirm && (flags.confirm === unbound || flags.confirm?.startsWith(`${unbound.slice(0, -1)},`))) {
170
+ fail("CREDENTIAL_CHANGED", "Credential binding differs from the previewed confirmation; preview again", operation, ["Run the command without --execute to obtain a confirmation for the current credential"]);
171
+ }
172
172
  const current = await definition.current?.(reader, parsed.data);
173
173
  const state = canonical(current?.state ?? null);
174
174
  const preview = store.redactor.payload({ profile: scope.profile, operation, target, effect: definition.effect,
175
- current: current?.state ?? null, proposed: request, confirm, noop: current?.noop === true });
175
+ current: current?.state ?? null, proposed: request, confirm, noop: current?.noop === true,
176
+ ...(credential ? { credential } : {}) });
176
177
  if (!flags.execute)
177
178
  return { kind: "dry-run", preview };
178
179
  if (preview.noop)
@@ -205,7 +206,7 @@ export function constructWriteCoordinator(options, dependencies) {
205
206
  authorizations.set(authorization, canonical(identity));
206
207
  let response;
207
208
  try {
208
- response = await connection.request(operation, { ...request, raw, rawOutput, authorization });
209
+ response = await connection.request(operation, { ...request, authorization });
209
210
  }
210
211
  catch (error) {
211
212
  authorizations.delete(authorization);
@@ -219,7 +220,7 @@ export function constructWriteCoordinator(options, dependencies) {
219
220
  }
220
221
  append("outcome", "SUCCESS", response.status);
221
222
  return { kind: "success", preview, auditId, status: response.status,
222
- response: Buffer.isBuffer(response.body) && raw ? response.body : store.redactor.payload(response.body), contentType: response.contentType };
223
+ response: store.redactor.payload(response.body) };
223
224
  }
224
225
  return { scope, run, reader };
225
226
  }
@@ -8,7 +8,7 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
8
8
  allowWrites: boolean;
9
9
  operations: readonly string[];
10
10
  }>;
11
- run: (operation: string, input: unknown, flags?: import("./writes-core.js").MutationOptions, raw?: import("./writes-core.js").RawWriteRoute, rawOutput?: import("./transport-core.js").RequestOptions["rawOutput"]) => Promise<{
11
+ run: (operation: string, input: unknown, flags?: import("./writes-core.js").MutationOptions) => Promise<{
12
12
  kind: "dry-run";
13
13
  preview: Readonly<{
14
14
  profile: string;
@@ -19,11 +19,14 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
19
19
  proposed: unknown;
20
20
  confirm: string;
21
21
  noop: boolean;
22
+ credential?: Readonly<{
23
+ id: string;
24
+ revision: number;
25
+ }>;
22
26
  }>;
23
27
  auditId?: undefined;
24
28
  status?: undefined;
25
29
  response?: undefined;
26
- contentType?: undefined;
27
30
  } | {
28
31
  kind: "noop";
29
32
  preview: Readonly<{
@@ -35,11 +38,14 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
35
38
  proposed: unknown;
36
39
  confirm: string;
37
40
  noop: boolean;
41
+ credential?: Readonly<{
42
+ id: string;
43
+ revision: number;
44
+ }>;
38
45
  }>;
39
46
  auditId?: undefined;
40
47
  status?: undefined;
41
48
  response?: undefined;
42
- contentType?: undefined;
43
49
  } | {
44
50
  kind: "success";
45
51
  preview: Readonly<{
@@ -51,11 +57,14 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
51
57
  proposed: unknown;
52
58
  confirm: string;
53
59
  noop: boolean;
60
+ credential?: Readonly<{
61
+ id: string;
62
+ revision: number;
63
+ }>;
54
64
  }>;
55
65
  auditId: `${string}-${string}-${string}-${string}-${string}`;
56
66
  status: number;
57
67
  response: unknown;
58
- contentType: string | null | undefined;
59
68
  }>;
60
69
  reader: {
61
70
  request: (name: string, options?: import("./transport-core.js").RequestOptions) => Promise<{
package/docs/commands.md CHANGED
@@ -117,7 +117,7 @@ Investigate Tenable One exposure and run explicitly guarded writes.
117
117
  | `tenable-axi initiative update` | Preview or update initiative |
118
118
  | `tenable-axi profile list` | List configured profiles without resolving secrets or contacting Tenable |
119
119
  | `tenable-axi raw get` | Read any Tenable API path on the exact origin with the selected profile keys |
120
- | `tenable-axi raw write` | Send one raw write when the profile allows writes and the operation list includes raw-write |
120
+ | `tenable-axi raw write` | Send one raw write to any validated Tenable API path with the selected file profile keys |
121
121
  | `tenable-axi setup hooks` | Explicitly install or repair local agent session integrations |
122
122
  | `tenable-axi software list` | Search software; the pinned API exposes no stable software ID |
123
123
  | `tenable-axi software properties` | Discover software properties and supported operators |
@@ -141,7 +141,7 @@ Investigate Tenable One exposure and run explicitly guarded writes.
141
141
  | `tenable-axi tag value update` | Update platform tag value |
142
142
 
143
143
  Run each command with `--help` for concise help.
144
- Writes default to preview and require configured operation scope even for previews.
144
+ Named writes default to preview and require configured operation scope even for previews.
145
145
 
146
146
  ## asset investigate
147
147
 
@@ -1089,7 +1089,7 @@ tenable-axi raw get --path /api/v1/t1/tags/search --query limit=5
1089
1089
 
1090
1090
  ## raw write
1091
1091
 
1092
- Send one raw write when the profile allows writes and the operation list includes raw-write
1092
+ Send one raw write to any validated Tenable API path with the selected file profile keys
1093
1093
 
1094
1094
  | Flag | Meaning |
1095
1095
  |---|---|
@@ -1099,15 +1099,11 @@ Send one raw write when the profile allows writes and the operation list include
1099
1099
  | `--path` | Required absolute API path such as /api/v1/... |
1100
1100
  | `--query` | URL query such as key=value |
1101
1101
  | `--body-file` | JSON body file or - for stdin |
1102
- | `--execute` | Send after exact confirmation; default preview only |
1103
- | `--dry-run` | Preview only; incompatible with --execute |
1104
- | `--confirm` | Exact preview confirmation |
1105
- | `--intent-id` | Optional durable intent identifier |
1106
1102
  | `--help` | Show help; default false |
1107
1103
 
1108
1104
  ```sh
1109
1105
  tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json
1110
- tenable-axi raw write --method PATCH --path /api/v1/example --body-file body.json --execute --confirm <preview confirm>
1106
+ tenable-axi raw write --method DELETE --path /api/v1/example
1111
1107
  ```
1112
1108
 
1113
1109
  ## setup hooks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowttl/tenable-axi",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Investigate Tenable One exposure and run explicitly guarded writes",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -84,13 +84,16 @@ A failed status read after creation retains the created job and audit ID with `c
84
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`.
85
85
  `doctor` makes eight module probes without retries; use it for access diagnosis, not before each case.
86
86
  Local reads: `auth status`, `profile list`, `config path`, `hook`, help and version.
87
- Configured home reads up to five live cards; the optional hook reads local posture only.
87
+ Configured home reads up to five live cards; the optional hook reports local named-command write posture.
88
88
 
89
89
  Exclude all `create/update/delete/bulk-delete`, `tag assignment add/remove`, `export * start` and `raw write` commands from read allowlists.
90
- Writes require a file profile's `allowWrites` and exact operation allowlist even for previews, followed by `--execute` and the exact preview `--confirm` string.
91
- `TENABLE_AXI_READ_ONLY=true` forces read-only.
90
+ Named writes require a file profile's `allowWrites` and exact operation allowlist even for previews, followed by `--execute` and the exact preview `--confirm` string.
91
+ `raw write` sends once immediately with no profile scope, preview, confirmation or journal.
92
+ `TENABLE_AXI_READ_ONLY=1` or `true` forces read-only, including for `raw write`.
93
+ Unset, `0` or `false` leaves raw writes open for file profiles, subject to the path and body security blocks.
94
+ An empty or malformed value fails closed with `CONFIG_INVALID`.
92
95
  Export downloads read remotely but create a local file at an explicit new output path; `setup hooks` changes local integration files and needs explicit installation intent.
93
- Users, roles, access control and credential minting are unavailable; raw HTTP is available through `raw get` and guarded `raw write` on validated paths.
96
+ Users, roles, access control and credential minting are unavailable; raw HTTP is available through `raw get` and `raw write` on validated paths.
94
97
 
95
98
  ## Help and failures
96
99
 
@@ -114,4 +117,5 @@ Exit 0 means success (still inspect completeness), 1 means operation/configurati
114
117
  | `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. |
115
118
  | `DEADLINE_EXCEEDED`, `REQUEST_BUDGET_EXCEEDED`, `BYTE_BUDGET_EXCEEDED`, `ROW_BUDGET_EXCEEDED` | Narrow filters/fields or resume a supplied cursor; never infer completeness. |
116
119
  | `EXPORT_NOT_READY` | Inspect job state before downloading; status waiting does not guarantee completion. |
117
- | `OPERATION_BLOCKED`, `OUTCOME_UNKNOWN` | Respect write guards; for unknown mutation outcomes follow the audit ID and read-back advice, never replay blindly. |
120
+ | `OPERATION_BLOCKED` | Check the command's operation scope and write guards. |
121
+ | `OUTCOME_UNKNOWN` | Read the target back before sending again and never replay the original request. Use the audit ID for named writes. |