@knowttl/tenable-axi 0.1.7 → 0.1.8

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
@@ -101,6 +101,7 @@ See [write safety](https://github.com/knowttl/tenable-axi/blob/main/docs/safety.
101
101
  | `TENABLE_AXI_ORIGIN` | Environment profile origin; only the exact commercial origin is valid | `https://cloud.tenable.com` |
102
102
  | `TENABLE_AXI_READ_ONLY` | Force read-only with `1` or `true` | Unset; profile policy applies |
103
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 |
104
105
  | `XDG_CONFIG_HOME`, `XDG_STATE_HOME` | Absolute Unix config/state bases | `~/.config`, `~/.local/state` |
105
106
  | `APPDATA`, `LOCALAPPDATA` | Absolute Windows config/state bases | `~/AppData/Roaming`, `~/AppData/Local` |
106
107
  | `CLAUDE_CONFIG_DIR`, `CODEX_HOME` | Hook configuration directories | `~/.claude`, `~/.codex` |
@@ -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
  }
@@ -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;
@@ -78,6 +82,10 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
78
82
  proposed: unknown;
79
83
  confirm: string;
80
84
  noop: boolean;
85
+ credential?: Readonly<{
86
+ id: string;
87
+ revision: number;
88
+ }>;
81
89
  }>;
82
90
  auditId?: undefined;
83
91
  status?: undefined;
@@ -94,6 +102,10 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
94
102
  proposed: unknown;
95
103
  confirm: string;
96
104
  noop: boolean;
105
+ credential?: Readonly<{
106
+ id: string;
107
+ revision: number;
108
+ }>;
97
109
  }>;
98
110
  auditId?: undefined;
99
111
  status?: undefined;
@@ -110,6 +122,10 @@ export declare function constructWriteCoordinator(options: WriteCoordinatorOptio
110
122
  proposed: unknown;
111
123
  confirm: string;
112
124
  noop: boolean;
125
+ credential?: Readonly<{
126
+ id: string;
127
+ revision: number;
128
+ }>;
113
129
  }>;
114
130
  auditId: `${string}-${string}-${string}-${string}-${string}`;
115
131
  status: number;
@@ -44,6 +44,7 @@ export function constructWriteCoordinator(options, dependencies) {
44
44
  const store = credentialStore(dependencies.credentials);
45
45
  const profile = store.select(store.load(options.config).config, options.profile);
46
46
  const forced = store.readOnly() || options.readOnly === true;
47
+ const credential = store.credentialBinding();
47
48
  const scope = Object.freeze({ profile: profile.name, origin: profile.origin,
48
49
  allowWrites: profile.source !== "env-profile" && profile.writes.allowWrites,
49
50
  operations: Object.freeze([...profile.writes.operations]) });
@@ -168,11 +169,17 @@ export function constructWriteCoordinator(options, dependencies) {
168
169
  const plan = connection.prepare(operation, { ...request, raw });
169
170
  const { effect: _effect, ...identity } = plan;
170
171
  const confirmationTarget = "payload" in target ? { kind: target.kind, digest: digest(canonical(request)) } : target;
171
- const confirm = canonical([scope.profile, operation, confirmationTarget]);
172
+ const unbound = canonical([scope.profile, operation, confirmationTarget]);
173
+ const confirm = credential ? canonical([scope.profile, operation, confirmationTarget,
174
+ `credential:${digest(`${credential.id}:${credential.revision}`)}`]) : unbound;
175
+ if (flags.execute && flags.confirm !== confirm && (flags.confirm === unbound || flags.confirm?.startsWith(`${unbound.slice(0, -1)},`))) {
176
+ 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"]);
177
+ }
172
178
  const current = await definition.current?.(reader, parsed.data);
173
179
  const state = canonical(current?.state ?? null);
174
180
  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 });
181
+ current: current?.state ?? null, proposed: request, confirm, noop: current?.noop === true,
182
+ ...(credential ? { credential } : {}) });
176
183
  if (!flags.execute)
177
184
  return { kind: "dry-run", preview };
178
185
  if (preview.noop)
@@ -19,6 +19,10 @@ 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;
@@ -35,6 +39,10 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
35
39
  proposed: unknown;
36
40
  confirm: string;
37
41
  noop: boolean;
42
+ credential?: Readonly<{
43
+ id: string;
44
+ revision: number;
45
+ }>;
38
46
  }>;
39
47
  auditId?: undefined;
40
48
  status?: undefined;
@@ -51,6 +59,10 @@ export declare function createWriteCoordinator(options?: WriteCoordinatorOptions
51
59
  proposed: unknown;
52
60
  confirm: string;
53
61
  noop: boolean;
62
+ credential?: Readonly<{
63
+ id: string;
64
+ revision: number;
65
+ }>;
54
66
  }>;
55
67
  auditId: `${string}-${string}-${string}-${string}-${string}`;
56
68
  status: number;
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.8",
4
4
  "description": "Investigate Tenable One exposure and run explicitly guarded writes",
5
5
  "license": "MIT",
6
6
  "type": "module",