@knowttl/tenable-axi 0.1.8 → 0.1.10

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,9 +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` |
104
- | `TENABLE_AXI_CREDENTIAL_REVISION` | Host credential binding as `<credential-id>:<revision>`; bound into write confirmations | Unset; confirmations carry no credential binding |
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 |
105
108
  | `XDG_CONFIG_HOME`, `XDG_STATE_HOME` | Absolute Unix config/state bases | `~/.config`, `~/.local/state` |
106
109
  | `APPDATA`, `LOCALAPPDATA` | Absolute Windows config/state bases | `~/AppData/Roaming`, `~/AppData/Local` |
107
110
  | `CLAUDE_CONFIG_DIR`, `CODEX_HOME` | Hook configuration directories | `~/.claude`, `~/.codex` |
@@ -133,7 +136,8 @@ See [behavior](https://github.com/knowttl/tenable-axi/blob/main/docs/behavior.md
133
136
  | `PERMISSION_DENIED` / HTTP 403 | Check licensing and the operation's privilege; run `doctor` for module-level advice. |
134
137
  | `CONFIG_INVALID` with environment credentials | Set both keys and use only the supported origin; partial environment profiles fail closed. |
135
138
  | `CONFIG_INSECURE` | Use an owned regular file with mode 600 on Unix or a protected Windows DACL. |
136
- | 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). |
137
141
  | Cursor rejected after collection changes | Restart without the cursor and retain the original selectors. |
138
142
 
139
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;
@@ -27,7 +27,7 @@ export const findingCountValues = {
27
27
  sensor_type: ["ACCURICS", "INVENTORY", "RAPID_7", "SECURITY_CENTER", "CARBON_BLACK", "TVDB", "AWS", "OT", "CONSEC", "WAS", "ASM", "NESSUS", "CLOUD_SCAN", "TIE"],
28
28
  };
29
29
  export const aliases = {
30
- asset: { class: "asset_class", exposureScore: "aes" }, finding: {}, software: { name: "application" },
30
+ asset: { class: "asset_class", exposureScore: "aes" }, finding: { cves: "finding_cves" }, software: { name: "application" },
31
31
  };
32
32
  export const wireFields = {
33
33
  asset: { id: z.string(), name: z.string(), asset_class: z.string(), aes: z.number(), acr: z.number() },
@@ -36,7 +36,7 @@ export const wireFields = {
36
36
  };
37
37
  export const extraFields = {
38
38
  asset: { fqdns: z.array(z.string()), last_observed_at: z.string() },
39
- finding: { cves: z.array(z.string()), sensor_type: z.string(), last_observed_at: z.string() },
39
+ finding: { finding_cves: z.array(z.string()), sensor_type: z.string(), last_observed_at: z.string() },
40
40
  software: {},
41
41
  };
42
42
  export const propertyFields = { key: z.string(), readable_name: z.string(), operators: z.array(z.string()),
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)
@@ -54,10 +54,7 @@ export type MutationOptions = {
54
54
  confirm?: string;
55
55
  intentId?: string;
56
56
  };
57
- export type RawWriteRoute = Readonly<{
58
- method: "POST" | "PUT" | "PATCH" | "DELETE";
59
- path: string;
60
- }>;
57
+ export declare function securityPayload(value: unknown): boolean;
61
58
  export declare function constructWriteCoordinator(options: WriteCoordinatorOptions, dependencies: {
62
59
  operations: Readonly<Record<string, MutationOperation>>;
63
60
  bindings: Readonly<Record<string, OperationBinding>>;
@@ -71,7 +68,7 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
71
68
  allowWrites: boolean;
72
69
  operations: readonly string[];
73
70
  }>;
74
- run: (operation: string, input: unknown, flags?: MutationOptions, raw?: RawWriteRoute, rawOutput?: RequestOptions["rawOutput"]) => Promise<{
71
+ run: (operation: string, input: unknown, flags?: MutationOptions) => Promise<{
75
72
  kind: "dry-run";
76
73
  preview: Readonly<{
77
74
  profile: string;
@@ -90,7 +87,6 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
90
87
  auditId?: undefined;
91
88
  status?: undefined;
92
89
  response?: undefined;
93
- contentType?: undefined;
94
90
  } | {
95
91
  kind: "noop";
96
92
  preview: Readonly<{
@@ -110,7 +106,6 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
110
106
  auditId?: undefined;
111
107
  status?: undefined;
112
108
  response?: undefined;
113
- contentType?: undefined;
114
109
  } | {
115
110
  kind: "success";
116
111
  preview: Readonly<{
@@ -130,7 +125,6 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
130
125
  auditId: `${string}-${string}-${string}-${string}-${string}`;
131
126
  status: number;
132
127
  response: unknown;
133
- contentType: string | null | undefined;
134
128
  }>;
135
129
  reader: {
136
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) => {
@@ -138,10 +133,10 @@ export function constructWriteCoordinator(options, dependencies) {
138
133
  }
139
134
  }
140
135
  }
141
- async function run(operation, input, flags = {}, raw, rawOutput) {
136
+ async function run(operation, input, flags = {}) {
142
137
  flags = { ...flags };
143
- const definition = raw ? rawWriteDefinition(raw) : Object.hasOwn(definitions, operation) ? definitions[operation] : undefined;
144
- if (!definition || (!raw && bindings[operation]?.effect !== "write"))
138
+ const definition = Object.hasOwn(definitions, operation) ? definitions[operation] : undefined;
139
+ if (!definition || bindings[operation]?.effect !== "write")
145
140
  fail("OPERATION_BLOCKED", "Operation has no reviewed write binding", operation);
146
141
  const parsed = definition.input.safeParse(input);
147
142
  if (!parsed.success)
@@ -149,8 +144,7 @@ export function constructWriteCoordinator(options, dependencies) {
149
144
  const prepared = definition.prepare(JSON.parse(canonical(parsed.data)));
150
145
  const request = JSON.parse(canonical(prepared.request));
151
146
  const target = JSON.parse(canonical(prepared.target));
152
- 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));
153
- if (securityField(request.body))
147
+ if (securityPayload(request.body))
154
148
  fail("VALIDATION_ERROR", "Security administration payloads are blocked", operation);
155
149
  const uuid = z.string().uuid();
156
150
  if (!target.kind?.trim() || ("id" in target ? !uuid.safeParse(target.id).success
@@ -166,7 +160,7 @@ export function constructWriteCoordinator(options, dependencies) {
166
160
  if (!scope.operations.includes(operation))
167
161
  fail("OPERATION_NOT_WRITABLE", "Operation is outside the configured write scope", operation);
168
162
  const connection = sender();
169
- const plan = connection.prepare(operation, { ...request, raw });
163
+ const plan = connection.prepare(operation, request);
170
164
  const { effect: _effect, ...identity } = plan;
171
165
  const confirmationTarget = "payload" in target ? { kind: target.kind, digest: digest(canonical(request)) } : target;
172
166
  const unbound = canonical([scope.profile, operation, confirmationTarget]);
@@ -212,7 +206,7 @@ export function constructWriteCoordinator(options, dependencies) {
212
206
  authorizations.set(authorization, canonical(identity));
213
207
  let response;
214
208
  try {
215
- response = await connection.request(operation, { ...request, raw, rawOutput, authorization });
209
+ response = await connection.request(operation, { ...request, authorization });
216
210
  }
217
211
  catch (error) {
218
212
  authorizations.delete(authorization);
@@ -226,7 +220,7 @@ export function constructWriteCoordinator(options, dependencies) {
226
220
  }
227
221
  append("outcome", "SUCCESS", response.status);
228
222
  return { kind: "success", preview, auditId, status: response.status,
229
- response: Buffer.isBuffer(response.body) && raw ? response.body : store.redactor.payload(response.body), contentType: response.contentType };
223
+ response: store.redactor.payload(response.body) };
230
224
  }
231
225
  return { scope, run, reader };
232
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;
@@ -27,7 +27,6 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
27
27
  auditId?: undefined;
28
28
  status?: undefined;
29
29
  response?: undefined;
30
- contentType?: undefined;
31
30
  } | {
32
31
  kind: "noop";
33
32
  preview: Readonly<{
@@ -47,7 +46,6 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
47
46
  auditId?: undefined;
48
47
  status?: undefined;
49
48
  response?: undefined;
50
- contentType?: undefined;
51
49
  } | {
52
50
  kind: "success";
53
51
  preview: Readonly<{
@@ -67,7 +65,6 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
67
65
  auditId: `${string}-${string}-${string}-${string}-${string}`;
68
66
  status: number;
69
67
  response: unknown;
70
- contentType: string | null | undefined;
71
68
  }>;
72
69
  reader: {
73
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.8",
3
+ "version": "0.1.10",
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. |