@astrofoundry/pi-astro 0.40.25 → 0.40.27
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/extensions/specialist-gate/approvals.test.ts +3 -0
- package/extensions/specialist-gate/index.ts +2 -2
- package/package.json +1 -1
- package/skills/network/SKILL.md +2 -0
- package/skills/proxmox/SKILL.md +3 -1
- package/specialists/README.md +2 -2
- package/specialists/network/run.ts +13 -0
- package/specialists/proxmox/run.ts +58 -15
- package/specialists/wrappers.test.ts +6 -2
|
@@ -21,6 +21,7 @@ describe("approvals", () => {
|
|
|
21
21
|
expect(isRisky("network", ["unifi", "mira", "--local", "write", "PUT", "/v1/sites/x/networks/y", "{}"])).toBe(true);
|
|
22
22
|
expect(isRisky("network", ["unifi", "mira", "nat-write", "POST", "{}"])).toBe(true);
|
|
23
23
|
expect(isRisky("network", ["unifi", "37", "nat"])).toBe(false);
|
|
24
|
+
expect(isRisky("network", ["unifi", "mira", "app-policy-delete", "0123456789abcdef01234567"])).toBe(true);
|
|
24
25
|
expect(isRisky("network", ["unifi", "mira", "device-network", "0123456789abcdef01234567", "{}"])).toBe(true);
|
|
25
26
|
expect(isRisky("network", ["unifi", "mira", "app-get", "/api/s/default/stat/device"])).toBe(false);
|
|
26
27
|
expect(isRisky("arcane", ["projects", "list"])).toBe(false);
|
|
@@ -43,6 +44,8 @@ describe("approvals", () => {
|
|
|
43
44
|
expect(isRisky("edge", ["vps", "reboot", "--confirm", "--help"])).toBe(false);
|
|
44
45
|
expect(isRisky("proxmox", ["guests"])).toBe(false);
|
|
45
46
|
expect(isRisky("proxmox", ["set", "107", "memory=768"])).toBe(true);
|
|
47
|
+
expect(isRisky("proxmox", ["space-x", "set", "105", "memory=768"])).toBe(true);
|
|
48
|
+
expect(isRisky("proxmox", ["space-x", "guests"])).toBe(false);
|
|
46
49
|
expect(isRisky("proxmox", ["shutdown", "107", "--confirm"])).toBe(true);
|
|
47
50
|
expect(isRisky("security", ["decisions"])).toBe(false);
|
|
48
51
|
expect(isRisky("inference", ["nexus-restart", "embed"])).toBe(true);
|
|
@@ -33,7 +33,7 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
|
|
|
33
33
|
],
|
|
34
34
|
identity: [/^zitadel\s+(DELETE|POST|PUT|PATCH)\b/, /^dmz\s+(deploy-config|pomerium-restart|render|lego-renew)\b/],
|
|
35
35
|
// Every UniFi write, on either console.
|
|
36
|
-
network: [/^unifi\s+\S+\s+(write|nat-write|device-network)\b/],
|
|
36
|
+
network: [/^unifi\s+\S+\s+(write|nat-write|device-network|app-policy-delete)\b/],
|
|
37
37
|
dns: [
|
|
38
38
|
/^technitium\s+primary\s+(zone-create|zone-catalog|zone-delete|record-add|record-update|record-delete|cluster-init|cluster-delete|cluster-remove|server-domain)\b/,
|
|
39
39
|
/^technitium\s+node\s+\S+\s+(server-domain|stale-zone-delete)\b/,
|
|
@@ -42,7 +42,7 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
|
|
|
42
42
|
],
|
|
43
43
|
edge: [/^vps\s+deploy-nginx\b/],
|
|
44
44
|
backup: [/^(vzdump-run|host-backup-run|arcane-backup-run|gcs-run|restic-check-run|restic-restore|restore-clean)\b/],
|
|
45
|
-
proxmox: [/^(set|snapshot-create|start)\b/],
|
|
45
|
+
proxmox: [/^(space-x\s+)?(set|snapshot-create|start)\b/],
|
|
46
46
|
inference: [/^(nexus-restart|nexus-start)\b/],
|
|
47
47
|
// media has no entry: trendarr cannot delete anything, and adds and queue toggles run on the caller's request.
|
|
48
48
|
};
|
package/package.json
CHANGED
package/skills/network/SKILL.md
CHANGED
|
@@ -94,6 +94,8 @@ Behavior learned on the live consoles:
|
|
|
94
94
|
|
|
95
95
|
`app-get` reads any path of the Network application's own API under `/api/s/default/` or `/v2/api/site/default/`, through the same connector and key. Use it to find the fields a change needs before adding a narrow write command. Useful reads: `/api/s/default/stat/device` (devices with `mgmt_network_id`, `config_network`, `port_table`, `port_overrides`, `uplink`), `/api/s/default/stat/sta` (clients with `ap_mac`, `sw_mac`, `sw_port`), `/api/s/default/rest/networkconf` (networks with their 24-hex ids, VLAN, subnet, DHCP range).
|
|
96
96
|
|
|
97
|
+
`app-policy-delete <policyId>` deletes a firewall policy that the official API lists with `id: null`, such as rules converted from the old firewall (Mira's `BLOCK INTERNET` rows on 2026-10-31). Find its 24-hex `_id` with `app-get /v2/api/site/default/firewall-policies`; every other policy change goes through `write`.
|
|
98
|
+
|
|
97
99
|
`device-network` changes only a device's management network and address: a PUT of `/api/s/default/rest/device/<deviceId>` whose body may hold just `mgmt_network_id` and `config_network`. Both sites use the same layout: the uplink port stays native Default with all VLANs tagged, and each device sits on Management with a static address and the local DNS nodes.
|
|
98
100
|
|
|
99
101
|
```json
|
package/skills/proxmox/SKILL.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: proxmox
|
|
3
|
-
description: How the proxmox specialist operates Proxmox VE on Pulsar through the proxmox tool.
|
|
3
|
+
description: How the proxmox specialist operates Proxmox VE on Pulsar (37) and SPACE-X (Mira) through the proxmox tool.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Proxmox specialist
|
|
7
7
|
|
|
8
8
|
Pulsar (`10.0.10.37`, Proxmox VE 9 on Debian 13, node name `pulsar`) runs every guest: VM 100 `arcane` (Docker platform), LXC 101 `hermes` (being retired by the operator; no specialist operates it), LXC 102 `backup` (GCS pusher), VM 103 `identity` (Zitadel), VM 104 `dmz` (Pomerium), LXC 105 `tailscale`, VM 106 `observability`, LXC 107 `technitium2`, LXC 108 `radius`. Storage `local-lvm` holds the disks, `unas-backup` the vzdump archives. The `proxmox` tool talks to the API with a token whose role allows audit everywhere and, on guests, power, snapshots, and CPU/memory/option/network settings; nothing else. `["--help"]` lists the commands.
|
|
9
9
|
|
|
10
|
+
SPACE-X (`10.1.10.37`, Proxmox VE 9 at Mira, node name `space-x`) runs LXC 100 `technitium3` (DNS cluster node) and LXC 105 `tailscale` (Mira's subnet router). Put `space-x` before any command to run it there, for example `["space-x", "guests"]`; without it every command runs on Pulsar. SPACE-X has the same restricted user `spc-proxmox@pve!cortex` with its own token, and the same forced-command key as Pulsar. SPACE-X has no backup storage yet.
|
|
11
|
+
|
|
10
12
|
## API commands
|
|
11
13
|
|
|
12
14
|
| Command | Effect |
|
package/specialists/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Host: Cortex (macOS on Apple silicon; Homebrew git; the specialists' Node, trend
|
|
|
40
40
|
- `edge`: `GCP_SA_KEY_JSON` (service account key), `SSH_KEY_FRONTDOOR_B64`, `HOMELAB_DEPLOY_KEY_B64`.
|
|
41
41
|
- `security`: `SSH_KEY_OBS_B64`.
|
|
42
42
|
- `backup`: `SSH_KEY_PULSAR_B64`, `SSH_KEY_ARCANE_B64`.
|
|
43
|
-
- `proxmox`: `PVE_TOKEN_ID` (plain, `spc-proxmox@pve!cortex`), `PVE_TOKEN_SECRET`, `SSH_KEY_PULSAR_B64
|
|
43
|
+
- `proxmox`: `PVE_TOKEN_ID` (plain, `spc-proxmox@pve!cortex`), `PVE_TOKEN_SECRET`, `PVE_SPACEX_TOKEN_ID` and `PVE_SPACEX_TOKEN_SECRET` (the same user on SPACE-X), `SSH_KEY_PULSAR_B64` (trusted by Pulsar and SPACE-X). `proxmox.json` also needs `spacexApiUrl`, `spacexCertSha256`, `spacexNode`, `spacexHost`, `spacexUser`, and `known_hosts` the SPACE-X host key.
|
|
44
44
|
- `inference`: `SSH_KEY_NEXUS_B64`.
|
|
45
45
|
- `media`: `TMDB_ACCESS_TOKEN` (TMDB API Read Access Token), `OMDB_API_KEY`, `RADARR_API_KEY`, `SONARR_API_KEY` (Settings, General, Security; each app has one), `SABNZBD_API_KEY` (the API key, not the NZB key, which can only add NZBs and cannot read or pause the queue).
|
|
46
46
|
2. **Identities.** Zitadel (`https://auth.37pla.net/ui/console`): service user `spc-arcane` with Access Token Type JWT and a JSON key; service user `spc-identity` with a Personal Access Token and the Instance Owner role. Technitium (cluster primary): user `spc-dns` in the Administrators group with an API token; the cluster syncs the user to every node. Cloudflare: an account-owned API token with `Zone:Read` and `DNS:Edit` on both zones. GCP project `frontdoor-1337`: service account `spc-edge` with `roles/iap.tunnelResourceAccessor` and `roles/compute.viewer`, JSON key. Proxmox (`ssh pulsar`): user `spc-proxmox@pve`, role `SpecialistGuest` = `VM.Audit VM.PowerMgmt VM.Snapshot VM.Snapshot.Rollback VM.Config.CPU VM.Config.Memory VM.Config.Options VM.Config.Network VM.Config.CDROM VM.GuestAgent.Audit`, ACLs `PVEAuditor` on `/` and `SpecialistGuest` on `/vms` for both the user and the token `spc-proxmox@pve!cortex` (`-privsep 1`).
|
|
@@ -151,6 +151,6 @@ The `astro-discord` extension gives Discord users access to the specialists from
|
|
|
151
151
|
|
|
152
152
|
## Rotation and operations
|
|
153
153
|
|
|
154
|
-
Rotation steps for every field live in the homelab repository, `03-cortex-macmini/ROTATION.md`. After any change in Vaultwarden run `specialist-cli provision`. Host state and the sudo rules are documented in `03-cortex-macmini/README.md`; the forced-command scripts are tracked under `02-pulsar-proxmox/dmz/system/`, `02-pulsar-proxmox/pulsar/system/`, `02-pulsar-proxmox/observability/system/`, `host/` of the `astronaute77/arcane` repository, `04-nexus-macstudio/system/`, and `00-frontdoor-vps/system/`.
|
|
154
|
+
Rotation steps for every field live in the homelab repository, `03-cortex-macmini/ROTATION.md`. After any change in Vaultwarden run `specialist-cli provision`. Host state and the sudo rules are documented in `03-cortex-macmini/README.md`; the forced-command scripts are tracked under `02-pulsar-proxmox/dmz/system/`, `02-pulsar-proxmox/pulsar/system/`, `06-space-x-proxmox/system/`, `02-pulsar-proxmox/observability/system/`, `host/` of the `astronaute77/arcane` repository, `04-nexus-macstudio/system/`, and `00-frontdoor-vps/system/`.
|
|
155
155
|
|
|
156
156
|
All nine planned specialists exist. See `AGENTS.md` for how to add one.
|
|
@@ -80,6 +80,8 @@ ${Object.values(UNIFI_READS)
|
|
|
80
80
|
unifi <37|mira> app-get <path> [--local] any GET of the Network application under /api/s/default/ or /v2/api/site/default/
|
|
81
81
|
unifi <37|mira> device-network <deviceId> <json> [--local]
|
|
82
82
|
set a device's management network and IP (keys mgmt_network_id, config_network)
|
|
83
|
+
unifi <37|mira> app-policy-delete <policyId> [--local]
|
|
84
|
+
delete a firewall policy the official API lists without an id
|
|
83
85
|
unifi <37|mira> nat [--local] the console's NAT rules (Policy Table; not in the official API)
|
|
84
86
|
unifi <37|mira> nat-write POST <json> | PUT <ruleId> <json> | DELETE <ruleId> [--local]
|
|
85
87
|
unifi <37|mira> fingerprint the local console's certificate fingerprint (for the pin)
|
|
@@ -223,6 +225,13 @@ export function deviceNetworkWrite(args: string[]): UnifiWrite {
|
|
|
223
225
|
return { method: "PUT", path: `/api/s/default/rest/device/${id}`, body };
|
|
224
226
|
}
|
|
225
227
|
|
|
228
|
+
/** `app-policy-delete <policyId>`: a firewall policy that the official API returns with `id: null` (rules converted from the old firewall). */
|
|
229
|
+
export function appPolicyDelete(args: string[]): UnifiWrite {
|
|
230
|
+
const [id, ...extra] = args;
|
|
231
|
+
if (id === undefined || !NAT_ID.test(id) || extra.length > 0) throw new UsageError("app-policy-delete <24-hex policyId from app-get /v2/api/site/default/firewall-policies>");
|
|
232
|
+
return { method: "DELETE", path: `/v2/api/site/default/firewall-policies/${id}` };
|
|
233
|
+
}
|
|
234
|
+
|
|
226
235
|
/** `nat-write POST <json>`, `nat-write PUT <ruleId> <json>`, or `nat-write DELETE <ruleId>`. */
|
|
227
236
|
export function natWrite(args: string[]): UnifiWrite {
|
|
228
237
|
const [method, first, second, ...extra] = args;
|
|
@@ -330,6 +339,10 @@ async function unifi(args: string[]): Promise<number> {
|
|
|
330
339
|
return 0;
|
|
331
340
|
}
|
|
332
341
|
if (rest[0] === "app-get") return printAnswer(await siteRequest(site, readSite(site), local, appGetPath(rest.slice(1)), "GET", undefined, "app"), `UniFi ${site} application`);
|
|
342
|
+
if (rest[0] === "app-policy-delete") {
|
|
343
|
+
const call = appPolicyDelete(rest.slice(1));
|
|
344
|
+
return printAnswer(await siteRequest(site, readSite(site), local, call.path, call.method, undefined, "app"), `UniFi ${site} policy`);
|
|
345
|
+
}
|
|
333
346
|
if (rest[0] === "device-network") {
|
|
334
347
|
const call = deviceNetworkWrite(rest.slice(1));
|
|
335
348
|
return printAnswer(await siteRequest(site, readSite(site), local, call.path, call.method, call.body, "app"), `UniFi ${site} device`);
|
|
@@ -23,6 +23,46 @@ interface ProxmoxConfig extends Record<string, string> {
|
|
|
23
23
|
|
|
24
24
|
const SHAPE = { apiUrl: "string", certSha256: "string", node: "string", pulsarHost: "string", pulsarUser: "string" } as const;
|
|
25
25
|
|
|
26
|
+
interface SpaceXConfig extends Record<string, string> {
|
|
27
|
+
spacexApiUrl: string;
|
|
28
|
+
spacexCertSha256: string;
|
|
29
|
+
spacexNode: string;
|
|
30
|
+
spacexHost: string;
|
|
31
|
+
spacexUser: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SPACEX_SHAPE = { spacexApiUrl: "string", spacexCertSha256: "string", spacexNode: "string", spacexHost: "string", spacexUser: "string" } as const;
|
|
35
|
+
|
|
36
|
+
/** Pulsar at 37 is the default host; a leading `space-x` selects Mira's host. */
|
|
37
|
+
export const HOSTS = ["pulsar", "space-x"] as const;
|
|
38
|
+
export type HostName = (typeof HOSTS)[number];
|
|
39
|
+
|
|
40
|
+
/** One Proxmox host: its API, token fields, and forced-command SSH target. */
|
|
41
|
+
interface Target {
|
|
42
|
+
name: HostName;
|
|
43
|
+
apiUrl: string;
|
|
44
|
+
certSha256: string;
|
|
45
|
+
node: string;
|
|
46
|
+
sshHost: string;
|
|
47
|
+
sshUser: string;
|
|
48
|
+
tokenIdField: string;
|
|
49
|
+
tokenSecretField: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function splitHost(args: string[]): { host: HostName; rest: string[] } {
|
|
53
|
+
return args[0] === "space-x" ? { host: "space-x", rest: args.slice(1) } : { host: "pulsar", rest: args };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readTarget(host: HostName): Target {
|
|
57
|
+
if (host === "space-x") {
|
|
58
|
+
const c = readConfig<SpaceXConfig>(SERVICE, SPACEX_SHAPE);
|
|
59
|
+
// SPACE-X trusts the same forced-command key as Pulsar (SSH_KEY_PULSAR); its API token is its own.
|
|
60
|
+
return { name: host, apiUrl: c.spacexApiUrl, certSha256: c.spacexCertSha256, node: c.spacexNode, sshHost: c.spacexHost, sshUser: c.spacexUser, tokenIdField: "PVE_SPACEX_TOKEN_ID", tokenSecretField: "PVE_SPACEX_TOKEN_SECRET" };
|
|
61
|
+
}
|
|
62
|
+
const c = readConfig<ProxmoxConfig>(SERVICE, SHAPE);
|
|
63
|
+
return { name: host, apiUrl: c.apiUrl, certSha256: c.certSha256, node: c.node, sshHost: c.pulsarHost, sshUser: c.pulsarUser, tokenIdField: "PVE_TOKEN_ID", tokenSecretField: "PVE_TOKEN_SECRET" };
|
|
64
|
+
}
|
|
65
|
+
|
|
26
66
|
const TIMEOUT_MS = 30_000;
|
|
27
67
|
const TASK_POLL_MS = 2_000;
|
|
28
68
|
const VMID = /^\d{3,9}$/;
|
|
@@ -50,7 +90,9 @@ export const HOST_COMMANDS: Readonly<Record<string, { args: number; help: string
|
|
|
50
90
|
export const GUEST_EXEC = ["status", "journal", "df", "updates"];
|
|
51
91
|
const SINCE = /^[A-Za-z0-9 :\-+]{1,40}$/;
|
|
52
92
|
|
|
53
|
-
const HELP = `proxmox specialist (Proxmox VE on Pulsar)
|
|
93
|
+
const HELP = `proxmox specialist (Proxmox VE on Pulsar at 37 and SPACE-X at Mira)
|
|
94
|
+
|
|
95
|
+
[space-x] <command> every command below runs on Pulsar, or on SPACE-X with the space-x prefix
|
|
54
96
|
|
|
55
97
|
guests every VM and container: vmid, name, type, status, resources (JSON)
|
|
56
98
|
guest <vmid> current status and configuration of one guest (JSON)
|
|
@@ -90,9 +132,9 @@ interface GuestResource {
|
|
|
90
132
|
tags?: string;
|
|
91
133
|
}
|
|
92
134
|
|
|
93
|
-
async function api(config:
|
|
94
|
-
const tokenId = readSecret(SERVICE,
|
|
95
|
-
const secret = readSecret(SERVICE,
|
|
135
|
+
async function api(config: Target, method: string, path: string, form?: Record<string, string>): Promise<unknown> {
|
|
136
|
+
const tokenId = readSecret(SERVICE, config.tokenIdField);
|
|
137
|
+
const secret = readSecret(SERVICE, config.tokenSecretField);
|
|
96
138
|
const body = form === undefined ? undefined : new URLSearchParams(form).toString();
|
|
97
139
|
const response = await pinnedRequest(new URL(`/api2/json${path}`, config.apiUrl), {
|
|
98
140
|
method,
|
|
@@ -147,7 +189,7 @@ export function needsConfirm(args: string[]): string[] {
|
|
|
147
189
|
return args.filter((_, i) => i !== index);
|
|
148
190
|
}
|
|
149
191
|
|
|
150
|
-
async function guestResource(config:
|
|
192
|
+
async function guestResource(config: Target, vmid: number): Promise<GuestResource> {
|
|
151
193
|
const resources = (await api(config, "GET", "/cluster/resources?type=vm")) as GuestResource[];
|
|
152
194
|
const guest = resources.find((r) => r.vmid === vmid);
|
|
153
195
|
if (!guest) throw new UsageError(`no guest with vmid ${vmid}`);
|
|
@@ -166,7 +208,7 @@ interface TaskStatus {
|
|
|
166
208
|
endtime?: number;
|
|
167
209
|
}
|
|
168
210
|
|
|
169
|
-
async function waitTask(config:
|
|
211
|
+
async function waitTask(config: Target, upid: string, timeoutMs: number): Promise<TaskStatus> {
|
|
170
212
|
const deadline = Date.now() + timeoutMs;
|
|
171
213
|
for (;;) {
|
|
172
214
|
const status = (await api(config, "GET", `/nodes/${config.node}/tasks/${encodeURIComponent(upid)}/status`)) as TaskStatus;
|
|
@@ -176,7 +218,7 @@ async function waitTask(config: ProxmoxConfig, upid: string, timeoutMs: number):
|
|
|
176
218
|
}
|
|
177
219
|
}
|
|
178
220
|
|
|
179
|
-
async function runTask(config:
|
|
221
|
+
async function runTask(config: Target, method: string, path: string, form: Record<string, string> | undefined, label: string): Promise<number> {
|
|
180
222
|
const upid = (await api(config, method, path, form)) as string;
|
|
181
223
|
const status = await waitTask(config, upid, 300_000);
|
|
182
224
|
printJson({ action: label, upid, exitstatus: status.exitstatus, endtime: status.endtime });
|
|
@@ -184,7 +226,7 @@ async function runTask(config: ProxmoxConfig, method: string, path: string, form
|
|
|
184
226
|
return 0;
|
|
185
227
|
}
|
|
186
228
|
|
|
187
|
-
async function apiCommand(config:
|
|
229
|
+
async function apiCommand(config: Target, args: string[]): Promise<number> {
|
|
188
230
|
const [name, ...rest] = args;
|
|
189
231
|
switch (name) {
|
|
190
232
|
case "guests": {
|
|
@@ -293,12 +335,12 @@ export function buildHostRemote(args: string[]): string {
|
|
|
293
335
|
return [name, ...rest].join(" ");
|
|
294
336
|
}
|
|
295
337
|
|
|
296
|
-
async function host(config:
|
|
338
|
+
async function host(config: Target, args: string[]): Promise<number> {
|
|
297
339
|
const remote = buildHostRemote(args);
|
|
298
340
|
const result = await sshFixed(
|
|
299
341
|
{
|
|
300
|
-
host: config.
|
|
301
|
-
user: config.
|
|
342
|
+
host: config.sshHost,
|
|
343
|
+
user: config.sshUser,
|
|
302
344
|
keyFile: secretPath(SERVICE, "SSH_KEY_PULSAR"),
|
|
303
345
|
knownHostsFile: join(specialistsHome(), "config", "known_hosts"),
|
|
304
346
|
},
|
|
@@ -315,14 +357,15 @@ export async function command(args: string[]): Promise<number> {
|
|
|
315
357
|
printRaw(HELP);
|
|
316
358
|
return 0;
|
|
317
359
|
}
|
|
318
|
-
const
|
|
319
|
-
|
|
360
|
+
const { host: hostName, rest } = splitHost(args);
|
|
361
|
+
const config = readTarget(hostName);
|
|
362
|
+
if (rest[0] === "fingerprint") {
|
|
320
363
|
const probe = await pinnedRequest(new URL("/", config.apiUrl), { method: "GET", headers: {}, expectedFingerprint: null, timeoutMs: TIMEOUT_MS });
|
|
321
364
|
printJson({ host: new URL(config.apiUrl).host, fingerprint256: probe.fingerprint });
|
|
322
365
|
return 0;
|
|
323
366
|
}
|
|
324
|
-
if (
|
|
325
|
-
return apiCommand(config,
|
|
367
|
+
if (rest[0] !== undefined && rest[0] in HOST_COMMANDS) return host(config, rest);
|
|
368
|
+
return apiCommand(config, rest);
|
|
326
369
|
}
|
|
327
370
|
|
|
328
371
|
if (process.argv[1] && import.meta.url === new URL(`file://${process.argv[1]}`).href) {
|
|
@@ -11,8 +11,8 @@ import { buildInferenceRemote, command as inferenceCommand } from "./inference/r
|
|
|
11
11
|
import { MAX_ADD_IDS, MAX_EXCLUDE_IDS, buildTrendarrCall, interpretRun, parseImdbIds, trendarrConfig, trendarrError, trendarrWarnings, command as mediaCommand } from "./media/run.ts";
|
|
12
12
|
import { ServiceError, UsageError } from "./lib/errors.ts";
|
|
13
13
|
import { safeRepoPath, safeWritePath } from "./lib/repo.ts";
|
|
14
|
-
import { appGetPath, buildPulsarRemote, cloudPath, deviceNetworkWrite, NAT_PATH, natWrite, parseQuery, parseSiteArgs, unifiPath, unifiWrite, command as networkCommand } from "./network/run.ts";
|
|
15
|
-
import { buildHostRemote, needsConfirm, parseSetPairs, parseVmid, validateApiPath as validatePvePath, command as proxmoxCommand } from "./proxmox/run.ts";
|
|
14
|
+
import { appGetPath, appPolicyDelete, buildPulsarRemote, cloudPath, deviceNetworkWrite, NAT_PATH, natWrite, parseQuery, parseSiteArgs, unifiPath, unifiWrite, command as networkCommand } from "./network/run.ts";
|
|
15
|
+
import { buildHostRemote, splitHost, needsConfirm, parseSetPairs, parseVmid, validateApiPath as validatePvePath, command as proxmoxCommand } from "./proxmox/run.ts";
|
|
16
16
|
import { banLength, buildObsRemote, compactDecisions, parseGoDuration, summariseAlerts, summariseVulns, summariseWazuh, vulnEvents, wazuhEvents, command as securityCommand } from "./security/run.ts";
|
|
17
17
|
|
|
18
18
|
describe("arcane wrapper", () => {
|
|
@@ -118,6 +118,8 @@ describe("network wrapper", () => {
|
|
|
118
118
|
it("limits application reads and device network writes", () => {
|
|
119
119
|
const id = "0123456789abcdef01234567";
|
|
120
120
|
expect(appGetPath(["/api/s/default/stat/device"])).toBe("/api/s/default/stat/device");
|
|
121
|
+
expect(appPolicyDelete(["0123456789abcdef01234567"])).toEqual({ method: "DELETE", path: "/v2/api/site/default/firewall-policies/0123456789abcdef01234567" });
|
|
122
|
+
expect(() => appPolicyDelete(["611cef69-df2e-4498-9845-8685daee84f3"])).toThrow(UsageError);
|
|
121
123
|
expect(appGetPath(["/v2/api/site/default/nat"])).toBe("/v2/api/site/default/nat");
|
|
122
124
|
expect(() => appGetPath(["/api/s/other/stat/device"])).toThrow(UsageError);
|
|
123
125
|
expect(() => appGetPath(["/api/s/default/../../x"])).toThrow(UsageError);
|
|
@@ -600,6 +602,8 @@ describe("proxmox wrapper", () => {
|
|
|
600
602
|
});
|
|
601
603
|
|
|
602
604
|
it("maps host commands to fixed remote strings", () => {
|
|
605
|
+
expect(splitHost(["space-x", "guests"])).toEqual({ host: "space-x", rest: ["guests"] });
|
|
606
|
+
expect(splitHost(["guests"])).toEqual({ host: "pulsar", rest: ["guests"] });
|
|
603
607
|
expect(buildHostRemote(["host-status"])).toBe("host-status");
|
|
604
608
|
expect(buildHostRemote(["guest-exec", "101", "df"])).toBe("guest-exec 101 df");
|
|
605
609
|
expect(() => buildHostRemote(["guest-exec", "101", "rm"])).toThrow(/action/);
|