@vellumai/cli 0.10.7-dev.202607101554.2aa9767 → 0.10.7-dev.202607101836.11f2eba

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.
@@ -1,6 +1,12 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
2
5
 
3
- import { resolveGatewayProxyTarget } from "../gateway-proxy";
6
+ import {
7
+ readAllowedGatewayPorts,
8
+ resolveGatewayProxyTarget,
9
+ } from "../gateway-proxy";
4
10
 
5
11
  const allow =
6
12
  (...ports: number[]) =>
@@ -64,6 +70,41 @@ describe("resolveGatewayProxyTarget", () => {
64
70
  });
65
71
  });
66
72
 
73
+ test("allowlists ports from resources, loopback URLs, and docker runtimeUrls — never remote URLs", () => {
74
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "gateway-proxy-test-"));
75
+ const lockfilePath = path.join(dir, "assistants.json");
76
+ try {
77
+ fs.writeFileSync(
78
+ lockfilePath,
79
+ JSON.stringify({
80
+ assistants: [
81
+ { assistantId: "local-a", resources: { gatewayPort: 7830 } },
82
+ { assistantId: "local-b", localUrl: "http://127.0.0.1:7831" },
83
+ // Docker entries record their published gateway only as a
84
+ // loopback runtimeUrl.
85
+ {
86
+ assistantId: "docker-a",
87
+ cloud: "docker",
88
+ runtimeUrl: "http://localhost:7930",
89
+ },
90
+ // Remote runtimeUrls (managed / gcp / paired) must never widen
91
+ // the allowlist.
92
+ {
93
+ assistantId: "remote-a",
94
+ cloud: "gcp",
95
+ runtimeUrl: "https://assistant.example.com:8443",
96
+ },
97
+ ],
98
+ }),
99
+ );
100
+ expect(readAllowedGatewayPorts([lockfilePath])).toEqual(
101
+ new Set([7830, 7831, 7930]),
102
+ );
103
+ } finally {
104
+ fs.rmSync(dir, { recursive: true, force: true });
105
+ }
106
+ });
107
+
67
108
  test("never reads the allowlist for non-gateway or invalid-port paths", () => {
68
109
  let reads = 0;
69
110
  const counting = () => {
@@ -87,6 +87,7 @@ export function readAllowedGatewayPorts(lockfilePaths: string[]): Set<number> {
87
87
  assistants?: Array<{
88
88
  gatewayUrl?: unknown;
89
89
  localUrl?: unknown;
90
+ runtimeUrl?: unknown;
90
91
  resources?: { gatewayPort?: unknown };
91
92
  }>;
92
93
  };
@@ -95,6 +96,10 @@ export function readAllowedGatewayPorts(lockfilePaths: string[]): Set<number> {
95
96
  if (!assistant) continue;
96
97
  addPortFromUrl(assistant.gatewayUrl, ports);
97
98
  addPortFromUrl(assistant.localUrl, ports);
99
+ // Docker entries record their published gateway as a loopback
100
+ // `runtimeUrl` with no `resources` block; the loopback-hostname filter
101
+ // in addPortFromUrl keeps remote runtimeUrls out of the allowlist.
102
+ addPortFromUrl(assistant.runtimeUrl, ports);
98
103
  const gp = assistant.resources?.gatewayPort;
99
104
  if (typeof gp === "number" && Number.isInteger(gp) && gp >= 1024 && gp <= 65535) {
100
105
  ports.add(gp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/cli",
3
- "version": "0.10.7-dev.202607101554.2aa9767",
3
+ "version": "0.10.7-dev.202607101836.11f2eba",
4
4
  "description": "CLI tools for vellum-assistant",
5
5
  "type": "module",
6
6
  "exports": {