@knowttl/tenable-axi 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +341 -2
- package/axi-credential.schema.json +28 -0
- package/bin/tenable-axi-hook.js +13 -0
- package/bin/tenable-axi.js +8 -0
- package/bin/version.js +3 -0
- package/dist/src/attack-catalogue.d.ts +176 -0
- package/dist/src/attack-catalogue.js +71 -0
- package/dist/src/attack-export-catalogue.d.ts +29 -0
- package/dist/src/attack-export-catalogue.js +58 -0
- package/dist/src/attack-export.d.ts +5 -0
- package/dist/src/attack-export.js +151 -0
- package/dist/src/attack.d.ts +3 -0
- package/dist/src/attack.js +287 -0
- package/dist/src/catalogue.d.ts +150 -0
- package/dist/src/catalogue.js +68 -0
- package/dist/src/cli.d.ts +11 -0
- package/dist/src/cli.js +61 -0
- package/dist/src/export-file.d.ts +8 -0
- package/dist/src/export-file.js +157 -0
- package/dist/src/exposure-contracts.d.ts +31 -0
- package/dist/src/exposure-contracts.js +31 -0
- package/dist/src/exposure.d.ts +4 -0
- package/dist/src/exposure.js +305 -0
- package/dist/src/hook-install.d.ts +1 -0
- package/dist/src/hook-install.js +132 -0
- package/dist/src/inventory/schema.d.ts +34 -0
- package/dist/src/inventory/schema.js +18 -0
- package/dist/src/inventory-catalogue.d.ts +55 -0
- package/dist/src/inventory-catalogue.js +61 -0
- package/dist/src/inventory-export-catalogue.d.ts +96 -0
- package/dist/src/inventory-export-catalogue.js +47 -0
- package/dist/src/inventory-export.d.ts +5 -0
- package/dist/src/inventory-export.js +162 -0
- package/dist/src/inventory.d.ts +3 -0
- package/dist/src/inventory.js +285 -0
- package/dist/src/local-commands.d.ts +2 -0
- package/dist/src/local-commands.js +44 -0
- package/dist/src/platform-tag-catalogue.d.ts +101 -0
- package/dist/src/platform-tag-catalogue.js +180 -0
- package/dist/src/platform-tag.d.ts +4 -0
- package/dist/src/platform-tag.js +312 -0
- package/dist/src/private-file.d.ts +18 -0
- package/dist/src/private-file.js +156 -0
- package/dist/src/profiles.d.ts +116 -0
- package/dist/src/profiles.js +147 -0
- package/dist/src/redact.d.ts +7 -0
- package/dist/src/redact.js +41 -0
- package/dist/src/response-catalogue.d.ts +41 -0
- package/dist/src/response-catalogue.js +134 -0
- package/dist/src/response.d.ts +4 -0
- package/dist/src/response.js +227 -0
- package/dist/src/setup.d.ts +1 -0
- package/dist/src/setup.js +39 -0
- package/dist/src/transport-core.d.ts +85 -0
- package/dist/src/transport-core.js +274 -0
- package/dist/src/transport.d.ts +4 -0
- package/dist/src/transport.js +6 -0
- package/dist/src/writes-core.d.ts +112 -0
- package/dist/src/writes-core.js +215 -0
- package/dist/src/writes.d.ts +57 -0
- package/dist/src/writes.js +5 -0
- package/docs/commands.md +1377 -0
- package/inventory/capabilities.json +3728 -0
- package/package.json +24 -4
- package/skills/tenable-axi/SKILL.md +101 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type CredentialContext } from "./profiles.js";
|
|
3
|
+
import { privateFiles } from "./private-file.js";
|
|
4
|
+
import { type OperationBinding, type RequestOptions, type Transport } from "./transport-core.js";
|
|
5
|
+
export type MutationTarget = {
|
|
6
|
+
kind: string;
|
|
7
|
+
id: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: string;
|
|
10
|
+
name: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: string;
|
|
13
|
+
ids: readonly string[];
|
|
14
|
+
} | {
|
|
15
|
+
kind: string;
|
|
16
|
+
payload: true;
|
|
17
|
+
};
|
|
18
|
+
export type MutationOperation = Readonly<{
|
|
19
|
+
input: z.ZodType;
|
|
20
|
+
prepare(input: unknown): {
|
|
21
|
+
target: MutationTarget;
|
|
22
|
+
request: Pick<RequestOptions, "pathParams" | "query" | "body">;
|
|
23
|
+
};
|
|
24
|
+
current?: (transport: Pick<Transport, "request">, input: unknown) => Promise<{
|
|
25
|
+
state: unknown;
|
|
26
|
+
noop?: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
effect: string;
|
|
29
|
+
readBackHelp: readonly string[];
|
|
30
|
+
}>;
|
|
31
|
+
export type MutationPreview = Readonly<{
|
|
32
|
+
profile: string;
|
|
33
|
+
operation: string;
|
|
34
|
+
target: MutationTarget;
|
|
35
|
+
effect: string;
|
|
36
|
+
current: unknown;
|
|
37
|
+
proposed: unknown;
|
|
38
|
+
confirm: string;
|
|
39
|
+
noop: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
export type WriteCoordinatorOptions = {
|
|
42
|
+
config?: string;
|
|
43
|
+
profile?: string;
|
|
44
|
+
readOnly?: boolean;
|
|
45
|
+
approval?: (preview: MutationPreview) => boolean | Promise<boolean>;
|
|
46
|
+
};
|
|
47
|
+
export type MutationOptions = {
|
|
48
|
+
execute?: boolean;
|
|
49
|
+
dryRun?: boolean;
|
|
50
|
+
confirm?: string;
|
|
51
|
+
intentId?: string;
|
|
52
|
+
};
|
|
53
|
+
export declare function constructWriteCoordinator(options: WriteCoordinatorOptions, dependencies: {
|
|
54
|
+
operations: Readonly<Record<string, MutationOperation>>;
|
|
55
|
+
bindings: Readonly<Record<string, OperationBinding>>;
|
|
56
|
+
fetch: typeof globalThis.fetch;
|
|
57
|
+
credentials?: CredentialContext;
|
|
58
|
+
files?: ReturnType<typeof privateFiles>;
|
|
59
|
+
}): {
|
|
60
|
+
scope: Readonly<{
|
|
61
|
+
profile: string;
|
|
62
|
+
origin: "https://cloud.tenable.com";
|
|
63
|
+
allowWrites: boolean;
|
|
64
|
+
operations: readonly string[];
|
|
65
|
+
}>;
|
|
66
|
+
run: (operation: string, input: unknown, flags?: MutationOptions) => Promise<{
|
|
67
|
+
kind: "dry-run";
|
|
68
|
+
preview: Readonly<{
|
|
69
|
+
profile: string;
|
|
70
|
+
operation: string;
|
|
71
|
+
target: MutationTarget;
|
|
72
|
+
effect: string;
|
|
73
|
+
current: unknown;
|
|
74
|
+
proposed: unknown;
|
|
75
|
+
confirm: string;
|
|
76
|
+
noop: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
auditId?: undefined;
|
|
79
|
+
status?: undefined;
|
|
80
|
+
response?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
kind: "noop";
|
|
83
|
+
preview: Readonly<{
|
|
84
|
+
profile: string;
|
|
85
|
+
operation: string;
|
|
86
|
+
target: MutationTarget;
|
|
87
|
+
effect: string;
|
|
88
|
+
current: unknown;
|
|
89
|
+
proposed: unknown;
|
|
90
|
+
confirm: string;
|
|
91
|
+
noop: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
auditId?: undefined;
|
|
94
|
+
status?: undefined;
|
|
95
|
+
response?: undefined;
|
|
96
|
+
} | {
|
|
97
|
+
kind: "success";
|
|
98
|
+
preview: Readonly<{
|
|
99
|
+
profile: string;
|
|
100
|
+
operation: string;
|
|
101
|
+
target: MutationTarget;
|
|
102
|
+
effect: string;
|
|
103
|
+
current: unknown;
|
|
104
|
+
proposed: unknown;
|
|
105
|
+
confirm: string;
|
|
106
|
+
noop: boolean;
|
|
107
|
+
}>;
|
|
108
|
+
auditId: `${string}-${string}-${string}-${string}-${string}`;
|
|
109
|
+
status: number;
|
|
110
|
+
response: unknown;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { lstatSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, resolve, win32 } from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { credentialStore } from "./profiles.js";
|
|
6
|
+
import { privateFiles } from "./private-file.js";
|
|
7
|
+
import { constructTransport, TransportError } from "./transport-core.js";
|
|
8
|
+
function canonical(value) {
|
|
9
|
+
const normalize = (value) => {
|
|
10
|
+
if (Array.isArray(value))
|
|
11
|
+
return value.map(normalize);
|
|
12
|
+
if (value && typeof value === "object")
|
|
13
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, child]) => [key, normalize(child)]));
|
|
14
|
+
return value;
|
|
15
|
+
};
|
|
16
|
+
return JSON.stringify(normalize(value));
|
|
17
|
+
}
|
|
18
|
+
const digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
19
|
+
const auditRecord = z.strictObject({
|
|
20
|
+
kind: z.enum(["intent", "outcome"]), time: z.string().datetime(), auditId: z.string().uuid(),
|
|
21
|
+
intentKey: z.string().regex(/^[a-f0-9]{64}$/), profile: z.string(), operation: z.string(),
|
|
22
|
+
target: z.string().regex(/^[a-f0-9]{64}$/), effect: z.literal("write"), status: z.number().int().min(100).max(599).optional(),
|
|
23
|
+
result: z.enum(["SUCCESS", "FAILED", "NOT_SENT", "OUTCOME_UNKNOWN"]).optional(),
|
|
24
|
+
}).superRefine((record, context) => {
|
|
25
|
+
const validOutcome = record.result === "SUCCESS" ? record.status !== undefined && record.status >= 200 && record.status < 300
|
|
26
|
+
: record.result === "FAILED" ? record.status !== undefined && record.status >= 300
|
|
27
|
+
: (record.result === "NOT_SENT" || record.result === "OUTCOME_UNKNOWN") && record.status === undefined;
|
|
28
|
+
if (record.kind === "intent" ? record.status !== undefined || record.result !== undefined : !validOutcome) {
|
|
29
|
+
context.addIssue({ code: "custom", message: "Invalid journal record" });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
// Internal seam, like constructTransport: production supplies the closed catalogue
|
|
33
|
+
// and native fetch. Tests supply synthetic operations and fake Tenable only.
|
|
34
|
+
export function constructWriteCoordinator(options, dependencies) {
|
|
35
|
+
options = { ...options };
|
|
36
|
+
const store = credentialStore(dependencies.credentials);
|
|
37
|
+
const profile = store.select(store.load(options.config).config, options.profile);
|
|
38
|
+
const forced = store.readOnly() || options.readOnly === true;
|
|
39
|
+
const scope = Object.freeze({ profile: profile.name, origin: profile.origin,
|
|
40
|
+
allowWrites: profile.source !== "env-profile" && profile.writes.allowWrites,
|
|
41
|
+
operations: Object.freeze([...profile.writes.operations]) });
|
|
42
|
+
const definitions = Object.fromEntries(Object.entries(dependencies.operations).map(([name, definition]) => [name, { ...definition, readBackHelp: [...definition.readBackHelp] }]));
|
|
43
|
+
const bindings = Object.fromEntries(Object.entries(dependencies.bindings).map(([name, binding]) => [name, { ...binding, query: [...binding.query], paging: [...(binding.paging ?? [])] }]));
|
|
44
|
+
const env = dependencies.credentials?.env ?? process.env;
|
|
45
|
+
const override = env.TENABLE_AXI_WRITE_LOG?.trim();
|
|
46
|
+
const platform = dependencies.credentials?.platform ?? process.platform;
|
|
47
|
+
const journalPath = override ? (platform === "win32" ? win32.resolve(override) : resolve(override))
|
|
48
|
+
: (platform === "win32" ? win32.join : join)(store.statePath(), "writes.log");
|
|
49
|
+
if (override && !(platform === "win32" ? /^[A-Za-z]:[\\/]/.test(override) : isAbsolute(override))) {
|
|
50
|
+
throw new TransportError({ code: "CONFIG_INVALID", message: "TENABLE_AXI_WRITE_LOG must be an absolute path", operation: "writes" });
|
|
51
|
+
}
|
|
52
|
+
const files = dependencies.files ?? privateFiles(dependencies.credentials);
|
|
53
|
+
let transport;
|
|
54
|
+
const authorizations = new WeakMap();
|
|
55
|
+
function sender() {
|
|
56
|
+
return transport ??= constructTransport({ keys: store.credentials(profile), origin: scope.origin }, {
|
|
57
|
+
bindings, fetch: dependencies.fetch,
|
|
58
|
+
consumeWriteAuthorization(authorization, request) {
|
|
59
|
+
if (!authorization || typeof authorization !== "object")
|
|
60
|
+
return false;
|
|
61
|
+
const expected = authorizations.get(authorization);
|
|
62
|
+
authorizations.delete(authorization);
|
|
63
|
+
return expected !== undefined && expected === canonical(request);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function fail(code, message, operation, help = [], auditId) {
|
|
68
|
+
throw new TransportError({ code, message, operation, ...(auditId ? { auditId } : {}) }, help);
|
|
69
|
+
}
|
|
70
|
+
function record(value) {
|
|
71
|
+
let release;
|
|
72
|
+
try {
|
|
73
|
+
release = files.lock(`${journalPath}.lock`);
|
|
74
|
+
let contents = "";
|
|
75
|
+
try {
|
|
76
|
+
lstatSync(journalPath);
|
|
77
|
+
contents = files.read(journalPath, true, true);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error.code !== "ENOENT")
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
if (contents && !contents.endsWith("\n"))
|
|
84
|
+
throw new Error("Incomplete journal");
|
|
85
|
+
const records = contents ? contents.slice(0, -1).split("\n").map((line) => auditRecord.parse(JSON.parse(line))) : [];
|
|
86
|
+
const intents = new Map();
|
|
87
|
+
const outcomes = new Set();
|
|
88
|
+
for (const prior of records) {
|
|
89
|
+
if (prior.kind === "intent") {
|
|
90
|
+
if (intents.has(prior.intentKey))
|
|
91
|
+
throw new Error("Duplicate intent");
|
|
92
|
+
intents.set(prior.intentKey, prior);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const intent = intents.get(prior.intentKey);
|
|
96
|
+
if (!intent || outcomes.has(prior.intentKey) || intent.auditId !== prior.auditId
|
|
97
|
+
|| intent.profile !== prior.profile || intent.operation !== prior.operation || intent.target !== prior.target || intent.effect !== prior.effect)
|
|
98
|
+
throw new Error("Invalid outcome");
|
|
99
|
+
outcomes.add(prior.intentKey);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (value.kind === "intent" && intents.has(value.intentKey)) {
|
|
103
|
+
fail("ALREADY_EXECUTED", "Intent was already reserved; reconcile it without replay", value.operation, [], value.auditId);
|
|
104
|
+
}
|
|
105
|
+
if (value.kind === "outcome" && (!intents.has(value.intentKey) || outcomes.has(value.intentKey)))
|
|
106
|
+
throw new Error("Missing intent");
|
|
107
|
+
files.write(journalPath, `${contents}${JSON.stringify(auditRecord.parse(store.redactor.payload(value)))}\n`);
|
|
108
|
+
release();
|
|
109
|
+
release = undefined;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error instanceof TransportError && error.error.code === "ALREADY_EXECUTED")
|
|
113
|
+
throw error;
|
|
114
|
+
fail(value.kind === "intent" ? "INTENT_NOT_RECORDED" : "OUTCOME_UNKNOWN", value.kind === "intent" ? "Intent could not be recorded; mutation was not sent" : "Outcome could not be recorded; remote success is possible", value.operation, ["Reconcile the private journal and any remaining lock manually; read back the target before retrying"], value.auditId);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
// An unresolved lock remains a fail-closed condition for later invocations.
|
|
118
|
+
if (release) {
|
|
119
|
+
try {
|
|
120
|
+
release();
|
|
121
|
+
}
|
|
122
|
+
catch { /* Preserve the structured journal failure. */ }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function run(operation, input, flags = {}) {
|
|
127
|
+
flags = { ...flags };
|
|
128
|
+
const definition = Object.hasOwn(definitions, operation) ? definitions[operation] : undefined;
|
|
129
|
+
if (!definition || bindings[operation]?.effect !== "write")
|
|
130
|
+
fail("OPERATION_BLOCKED", "Operation has no reviewed write binding", operation);
|
|
131
|
+
const parsed = definition.input.safeParse(input);
|
|
132
|
+
if (!parsed.success)
|
|
133
|
+
fail("VALIDATION_ERROR", "Invalid mutation input; check the named operation's schema", operation);
|
|
134
|
+
const prepared = definition.prepare(JSON.parse(canonical(parsed.data)));
|
|
135
|
+
const request = JSON.parse(canonical(prepared.request));
|
|
136
|
+
const target = JSON.parse(canonical(prepared.target));
|
|
137
|
+
const securityField = (value) => !!value && typeof value === "object" && Object.entries(value).some(([key, child]) => /^(?:access_control|permissions|roles|credentials|api_keys)$/i.test(key) || securityField(child));
|
|
138
|
+
if (securityField(request.body))
|
|
139
|
+
fail("VALIDATION_ERROR", "Security administration payloads are blocked", operation);
|
|
140
|
+
const uuid = z.string().uuid();
|
|
141
|
+
if (!target.kind?.trim() || ("id" in target ? !uuid.safeParse(target.id).success
|
|
142
|
+
: "name" in target ? !target.name.trim() : "ids" in target ? !target.ids.length || target.ids.some((id) => !uuid.safeParse(id).success)
|
|
143
|
+
: target.payload !== true))
|
|
144
|
+
fail("VALIDATION_ERROR", "An exact mutation target is required", operation);
|
|
145
|
+
if ("ids" in target)
|
|
146
|
+
target.ids = [...new Set(target.ids)].sort();
|
|
147
|
+
if (flags.execute && flags.dryRun)
|
|
148
|
+
fail("VALIDATION_ERROR", "--execute and --dry-run are mutually exclusive", operation);
|
|
149
|
+
if (forced || store.readOnly() || !scope.allowWrites)
|
|
150
|
+
fail("WRITES_DISABLED", "Writes are disabled for the selected profile", operation);
|
|
151
|
+
if (!scope.operations.includes(operation))
|
|
152
|
+
fail("OPERATION_NOT_WRITABLE", "Operation is outside the configured write scope", operation);
|
|
153
|
+
const connection = sender();
|
|
154
|
+
const plan = connection.prepare(operation, request);
|
|
155
|
+
const { effect: _effect, ...identity } = plan;
|
|
156
|
+
const confirmationTarget = "payload" in target ? { kind: target.kind, digest: digest(canonical(request)) } : target;
|
|
157
|
+
const confirm = canonical([scope.profile, operation, confirmationTarget]);
|
|
158
|
+
const reader = { request: async (name, options) => {
|
|
159
|
+
if (connection.prepare(name, options).effect !== "read")
|
|
160
|
+
fail("OPERATION_BLOCKED", "State readers cannot send writes", operation);
|
|
161
|
+
return connection.request(name, options);
|
|
162
|
+
} };
|
|
163
|
+
const current = await definition.current?.(reader, parsed.data);
|
|
164
|
+
const state = canonical(current?.state ?? null);
|
|
165
|
+
const preview = store.redactor.payload({ profile: scope.profile, operation, target, effect: definition.effect,
|
|
166
|
+
current: current?.state ?? null, proposed: request, confirm, noop: current?.noop === true });
|
|
167
|
+
if (!flags.execute)
|
|
168
|
+
return { kind: "dry-run", preview };
|
|
169
|
+
if (preview.noop)
|
|
170
|
+
return { kind: "noop", preview };
|
|
171
|
+
// Redaction must never turn an exact-target check into a different approval.
|
|
172
|
+
if (preview.confirm !== confirm)
|
|
173
|
+
fail("CONFIRM_UNSAFE", "Target contains credential material; choose a safe target", operation);
|
|
174
|
+
if (flags.confirm !== confirm)
|
|
175
|
+
fail(flags.confirm === undefined ? "CONFIRM_REQUIRED" : "CONFIRM_MISMATCH", "Pass --confirm equal to the exact preview confirmation", operation);
|
|
176
|
+
if (options.approval && !await options.approval(structuredClone(preview)))
|
|
177
|
+
fail("APPROVAL_DENIED", "Host approval was denied", operation);
|
|
178
|
+
if (flags.intentId !== undefined && !flags.intentId.trim())
|
|
179
|
+
fail("VALIDATION_ERROR", "Intent ID must not be blank", operation);
|
|
180
|
+
const auditId = randomUUID();
|
|
181
|
+
const meta = { auditId, intentKey: digest(flags.intentId ?? auditId), profile: scope.profile, operation,
|
|
182
|
+
target: digest(canonical(confirmationTarget)), effect: "write" };
|
|
183
|
+
const append = (kind, result, status) => record({ ...meta, kind,
|
|
184
|
+
time: new Date().toISOString(), ...(result === undefined ? {} : { result }), ...(status === undefined ? {} : { status }) });
|
|
185
|
+
append("intent");
|
|
186
|
+
try {
|
|
187
|
+
const fresh = await definition.current?.(reader, parsed.data);
|
|
188
|
+
if (canonical(fresh?.state ?? null) !== state)
|
|
189
|
+
fail("PREVIEW_CHANGED", "Target changed after preview; review it again", operation);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
append("outcome", "NOT_SENT");
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
const authorization = Object.freeze({});
|
|
196
|
+
authorizations.set(authorization, canonical(identity));
|
|
197
|
+
let response;
|
|
198
|
+
try {
|
|
199
|
+
response = await connection.request(operation, { ...request, authorization });
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
authorizations.delete(authorization);
|
|
203
|
+
const upstream = error instanceof TransportError ? error : undefined;
|
|
204
|
+
const status = upstream?.error.status;
|
|
205
|
+
const unknown = upstream?.error.code === "OUTCOME_UNKNOWN" || status === undefined;
|
|
206
|
+
append("outcome", unknown ? "OUTCOME_UNKNOWN" : status >= 200 && status < 300 ? "SUCCESS" : "FAILED", status);
|
|
207
|
+
if (unknown)
|
|
208
|
+
fail("OUTCOME_UNKNOWN", "Mutation may have been applied; never replay this intent", operation, definition.readBackHelp, auditId);
|
|
209
|
+
throw new TransportError({ ...upstream.error, auditId }, upstream.help);
|
|
210
|
+
}
|
|
211
|
+
append("outcome", "SUCCESS", response.status);
|
|
212
|
+
return { kind: "success", preview, auditId, status: response.status, response: store.redactor.payload(response.body) };
|
|
213
|
+
}
|
|
214
|
+
return { scope, run };
|
|
215
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type WriteCoordinatorOptions } from "./writes-core.js";
|
|
2
|
+
import type { CredentialContext } from "./profiles.js";
|
|
3
|
+
export type { MutationTarget, MutationOperation, MutationOptions, MutationPreview, WriteCoordinatorOptions } from "./writes-core.js";
|
|
4
|
+
export declare function createWriteCoordinator(options?: WriteCoordinatorOptions, credentials?: CredentialContext): {
|
|
5
|
+
scope: Readonly<{
|
|
6
|
+
profile: string;
|
|
7
|
+
origin: "https://cloud.tenable.com";
|
|
8
|
+
allowWrites: boolean;
|
|
9
|
+
operations: readonly string[];
|
|
10
|
+
}>;
|
|
11
|
+
run: (operation: string, input: unknown, flags?: import("./writes-core.js").MutationOptions) => Promise<{
|
|
12
|
+
kind: "dry-run";
|
|
13
|
+
preview: Readonly<{
|
|
14
|
+
profile: string;
|
|
15
|
+
operation: string;
|
|
16
|
+
target: import("./writes-core.js").MutationTarget;
|
|
17
|
+
effect: string;
|
|
18
|
+
current: unknown;
|
|
19
|
+
proposed: unknown;
|
|
20
|
+
confirm: string;
|
|
21
|
+
noop: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
auditId?: undefined;
|
|
24
|
+
status?: undefined;
|
|
25
|
+
response?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "noop";
|
|
28
|
+
preview: Readonly<{
|
|
29
|
+
profile: string;
|
|
30
|
+
operation: string;
|
|
31
|
+
target: import("./writes-core.js").MutationTarget;
|
|
32
|
+
effect: string;
|
|
33
|
+
current: unknown;
|
|
34
|
+
proposed: unknown;
|
|
35
|
+
confirm: string;
|
|
36
|
+
noop: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
auditId?: undefined;
|
|
39
|
+
status?: undefined;
|
|
40
|
+
response?: undefined;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "success";
|
|
43
|
+
preview: Readonly<{
|
|
44
|
+
profile: string;
|
|
45
|
+
operation: string;
|
|
46
|
+
target: import("./writes-core.js").MutationTarget;
|
|
47
|
+
effect: string;
|
|
48
|
+
current: unknown;
|
|
49
|
+
proposed: unknown;
|
|
50
|
+
confirm: string;
|
|
51
|
+
noop: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
auditId: `${string}-${string}-${string}-${string}-${string}`;
|
|
54
|
+
status: number;
|
|
55
|
+
response: unknown;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { mutationOperations, transportBindings } from "./catalogue.js";
|
|
2
|
+
import { constructWriteCoordinator } from "./writes-core.js";
|
|
3
|
+
export function createWriteCoordinator(options = {}, credentials) {
|
|
4
|
+
return constructWriteCoordinator(options, { operations: mutationOperations, bindings: transportBindings, fetch: globalThis.fetch, credentials });
|
|
5
|
+
}
|