@infosupport/huddle-cli 0.0.0-experiment-97.41.1 → 0.0.0-experiment-98.44.1

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/dist/config.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CONFIG_DIR = void 0;
6
7
  exports.configPath = configPath;
7
8
  exports.readConfig = readConfig;
8
9
  exports.writeConfig = writeConfig;
@@ -12,8 +13,8 @@ exports.imageTag = imageTag;
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const os_1 = __importDefault(require("os"));
14
15
  const path_1 = __importDefault(require("path"));
15
- const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.huddle');
16
- const CONFIG_PATH = path_1.default.join(CONFIG_DIR, 'config.json');
16
+ exports.CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.huddle');
17
+ const CONFIG_PATH = path_1.default.join(exports.CONFIG_DIR, 'config.json');
17
18
  function configPath() {
18
19
  return CONFIG_PATH;
19
20
  }
@@ -26,7 +27,7 @@ function readConfig() {
26
27
  }
27
28
  }
28
29
  function writeConfig(config) {
29
- fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true });
30
+ fs_1.default.mkdirSync(exports.CONFIG_DIR, { recursive: true });
30
31
  fs_1.default.writeFileSync(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`);
31
32
  }
32
33
  /** Operator-token voor API-auth: env wint, anders uit de config. */
package/dist/firewall.js CHANGED
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.runFirewallList = runFirewallList;
4
7
  exports.runFirewallAdd = runFirewallAdd;
5
8
  exports.runFirewallDelete = runFirewallDelete;
9
+ exports.runFirewallExport = runFirewallExport;
10
+ exports.runFirewallImport = runFirewallImport;
11
+ exports.runFirewallGroup = runFirewallGroup;
12
+ exports.runFirewallFolder = runFirewallFolder;
13
+ const fs_1 = __importDefault(require("fs"));
6
14
  const api_1 = require("./api");
15
+ const config_1 = require("./config");
7
16
  const utils_1 = require("./utils");
8
17
  async function runFirewallList(opts) {
9
18
  const qs = new URLSearchParams({ status: opts.status ?? 'requested' });
@@ -56,9 +65,9 @@ async function resolveRule(rule, status, scope) {
56
65
  }
57
66
  // Creates a custom firewall rule. Supports wildcards: `*.` in the domain
58
67
  // (e.g. `*.pkgs.dev.azure.com`) and `*` in the path pattern (e.g.
59
- // `/_packaging/*/nuget/v3/*` for an Azure DevOps feed with a rotating
60
- // GUID). Defaults to 'allow'; with --deny a block rule. Without --container the
61
- // rule is global.
68
+ // `/_packaging/*/nuget/v3/*` for an Azure DevOps feed with a changing
69
+ // GUID). Defaults to 'allow'; --deny creates a block rule. Without --container
70
+ // the rule is global.
62
71
  async function runFirewallAdd(opts) {
63
72
  const domain = (opts.domain ?? '').trim();
64
73
  if (!domain) {
@@ -135,3 +144,137 @@ function printRulesTable(rules) {
135
144
  function formatTarget(rule) {
136
145
  return rule.path_pattern ? `${rule.domain}${rule.path_pattern}` : rule.domain;
137
146
  }
147
+ async function runFirewallExport(opts) {
148
+ const qs = new URLSearchParams();
149
+ if (opts.container)
150
+ qs.set('container', opts.container);
151
+ const suffix = qs.toString() ? `?${qs}` : '';
152
+ const doc = await (0, api_1.get)(`/api/rules/export${suffix}`);
153
+ const json = JSON.stringify(doc, null, 2);
154
+ if (opts.out) {
155
+ fs_1.default.writeFileSync(opts.out, `${json}\n`);
156
+ // Progress to stderr so a pure `--out` run leaks nothing to stdout.
157
+ console.error((0, utils_1.green)(`[OK] Exported ${doc.rules.length} rule(s) to ${opts.out}`));
158
+ }
159
+ else {
160
+ console.log(json);
161
+ }
162
+ }
163
+ // Read + JSON-parse a file with uniform, actionable errors. Shared by both
164
+ // import paths (flat rules and groups).
165
+ function readJsonFile(file) {
166
+ let raw;
167
+ try {
168
+ raw = fs_1.default.readFileSync(file, 'utf8');
169
+ }
170
+ catch {
171
+ throw new Error(`Cannot read ${file}`);
172
+ }
173
+ try {
174
+ return JSON.parse(raw);
175
+ }
176
+ catch {
177
+ throw new Error(`${file} is not valid JSON`);
178
+ }
179
+ }
180
+ async function runFirewallImport(opts) {
181
+ const doc = readJsonFile(opts.file);
182
+ const mode = opts.replace ? 'replace' : 'merge';
183
+ const qs = new URLSearchParams();
184
+ if (opts.container)
185
+ qs.set('container', opts.container);
186
+ const suffix = qs.toString() ? `?${qs}` : '';
187
+ const res = await (0, api_1.post)(`/api/rules/import${suffix}`, { mode, rules: doc.rules });
188
+ console.error((0, utils_1.green)(`[OK] Imported (${mode}): ${res.imported} added, ${res.updated} updated, ${res.skipped} skipped`));
189
+ }
190
+ async function resolveGroupByName(name) {
191
+ const groups = await (0, api_1.get)('/api/groups');
192
+ const match = groups.filter((g) => g.name.toLowerCase() === name.toLowerCase());
193
+ if (match.length === 0)
194
+ throw new Error(`No group named "${name}". Run \`huddle firewall group list\`.`);
195
+ return match[0];
196
+ }
197
+ async function runFirewallGroup(opts) {
198
+ const action = opts.action ?? 'list';
199
+ if (action === 'list') {
200
+ const groups = await (0, api_1.get)('/api/groups');
201
+ if (groups.length === 0) {
202
+ console.log((0, utils_1.dim)('No firewall groups yet.'));
203
+ return;
204
+ }
205
+ const headers = ['ID', 'Name', 'Rules', 'Shared', 'Source'];
206
+ const rows = groups.map((g) => [String(g.id), g.name, String(g.rule_count), g.shared ? 'yes' : 'no', g.source]);
207
+ (0, utils_1.printTable)(headers, rows);
208
+ return;
209
+ }
210
+ if (action === 'export') {
211
+ const name = (opts.arg ?? '').trim();
212
+ if (!name)
213
+ throw new Error('Usage: huddle firewall group export <name> [--out <file>]');
214
+ const g = await resolveGroupByName(name);
215
+ const env = await (0, api_1.get)(`/api/groups/${g.id}/export`);
216
+ const json = JSON.stringify(env, null, 2);
217
+ if (opts.out) {
218
+ fs_1.default.writeFileSync(opts.out, `${json}\n`);
219
+ console.error((0, utils_1.green)(`[OK] Exported group "${g.name}" to ${opts.out}`));
220
+ }
221
+ else {
222
+ console.log(json);
223
+ }
224
+ return;
225
+ }
226
+ if (action === 'import') {
227
+ const file = (opts.arg ?? '').trim();
228
+ if (!file)
229
+ throw new Error('Usage: huddle firewall group import <file> [--replace]');
230
+ const envelope = readJsonFile(file);
231
+ const mode = opts.replace ? 'replace' : 'merge';
232
+ const res = await (0, api_1.post)('/api/groups/import', { mode, envelope });
233
+ console.error((0, utils_1.green)(`[OK] Imported group "${res.group.name}" (${mode}): ${res.imported} added, ${res.updated} updated, ${res.skipped} skipped`));
234
+ return;
235
+ }
236
+ if (action === 'apply') {
237
+ const name = (opts.arg ?? '').trim();
238
+ if (!name)
239
+ throw new Error('Usage: huddle firewall group apply <name> [--container <id>]');
240
+ const g = await resolveGroupByName(name);
241
+ const container = opts.container ?? null;
242
+ const res = await (0, api_1.post)(`/api/groups/${g.id}/apply`, { container });
243
+ const scope = container ? `container ${container}` : 'global';
244
+ console.log((0, utils_1.green)(`[OK] Applied "${g.name}" to ${scope}: ${res.applied} added, ${res.updated} updated`));
245
+ return;
246
+ }
247
+ throw new Error(`Unknown group action: ${action}. Use list | export | import | apply.`);
248
+ }
249
+ async function runFirewallFolder(opts) {
250
+ const action = opts.action ?? 'show';
251
+ if (action === 'show') {
252
+ // The CLI config is the source of truth for the path.
253
+ const folder = (0, config_1.readConfig)().firewallRulesFolder;
254
+ console.log(folder ? folder : (0, utils_1.dim)('(no firewall rules folder configured)'));
255
+ return;
256
+ }
257
+ if (action === 'set') {
258
+ const path = (opts.path ?? '').trim();
259
+ if (!path)
260
+ throw new Error('Usage: huddle firewall folder set <path>');
261
+ // Config-only: the gateway reads the folder at the fixed mount point the CLI
262
+ // binds it to; there is no DB setting. Persist here and mount on restart.
263
+ (0, config_1.writeConfig)({ ...(0, config_1.readConfig)(), firewallRulesFolder: path });
264
+ console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)}`));
265
+ console.log((0, utils_1.dim)(' Run `huddle restart` to mount it into the gateway; it is then read on start & reload.'));
266
+ return;
267
+ }
268
+ if (action === 'reload') {
269
+ const res = await (0, api_1.post)('/api/firewall-rules-folder/reload', {});
270
+ if (!res.mounted) {
271
+ console.log((0, utils_1.dim)('No firewall rules folder mounted. Set one with `huddle firewall folder set <path>` and run `huddle restart`.'));
272
+ return;
273
+ }
274
+ console.log((0, utils_1.green)(`[OK] Reloaded: ${res.groups} group(s), ${res.imported} rule(s), ${res.errors.length} error(s)`));
275
+ for (const e of res.errors)
276
+ console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
277
+ return;
278
+ }
279
+ throw new Error(`Unknown folder action: ${action}. Use show | set | reload.`);
280
+ }
package/dist/images.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveImages = resolveImages;
4
- exports.gatewayEnvFlags = gatewayEnvFlags;
4
+ exports.gatewayEnvArgs = gatewayEnvArgs;
5
5
  const config_1 = require("./config");
6
6
  function resolveImages() {
7
7
  const experiment = (0, config_1.activeExperiment)();
@@ -19,13 +19,17 @@ function resolveImages() {
19
19
  };
20
20
  }
21
21
  /**
22
- * `-e` flags for the gateway container. During an experiment (or with an
23
- * explicit override) the gateway must start devcontainers from the same
24
- * base images the CLI just pulled.
22
+ * `-e KEY=val` argv pairs for the gateway container. During an experiment (or
23
+ * with an explicit override) the gateway must start devcontainers from the same
24
+ * base images the CLI just pulled. Returned as an argv array (not a shell
25
+ * string) so init can spawn `docker run` without a shell.
25
26
  */
26
- function gatewayEnvFlags(resolved) {
27
- return resolved.baseImages
28
- .filter((b) => b.gatewayEnv && (resolved.experiment !== undefined || process.env[b.gatewayEnv]))
29
- .map((b) => ` -e ${b.gatewayEnv}=${b.image}`)
30
- .join('');
27
+ function gatewayEnvArgs(resolved) {
28
+ const args = [];
29
+ for (const b of resolved.baseImages) {
30
+ if (b.gatewayEnv && (resolved.experiment !== undefined || process.env[b.gatewayEnv])) {
31
+ args.push('-e', `${b.gatewayEnv}=${b.image}`);
32
+ }
33
+ }
34
+ return args;
31
35
  }
package/dist/index.js CHANGED
@@ -15,9 +15,9 @@ const images_1 = require("./images");
15
15
  const self_update_1 = require("./self-update");
16
16
  const utils_1 = require("./utils");
17
17
  const experiment_1 = require("./experiment");
18
- const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output']);
19
- const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force']);
20
- const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'experiment', 'migrate', 'help', 'version']);
18
+ const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out']);
19
+ const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace']);
20
+ const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'help', 'version']);
21
21
  function parseArgs(argv) {
22
22
  const positional = [];
23
23
  const flags = {};
@@ -94,6 +94,8 @@ Usage:
94
94
  huddle start [options] [folder] Explicitly start a devcontainer
95
95
  huddle init [options] Pull the Huddle + devcontainer base images and
96
96
  start them via Docker or Podman
97
+ huddle restart Recreate the gateway (e.g. to mount a changed
98
+ team firewall-rules folder)
97
99
  huddle migrate [folder] Wire an existing docker-compose devcontainer
98
100
  behind Huddle by generating an override file
99
101
  huddle firewall list [options] Show firewall requests
@@ -102,6 +104,14 @@ Usage:
102
104
  supported: *.example.com and /path/*)
103
105
  huddle firewall delete <id> Delete a firewall rule by id (or domain;
104
106
  narrow with --container)
107
+ huddle firewall export [options] Export firewall rules as JSON
108
+ huddle firewall import <file> Import firewall rules from a JSON file
109
+ huddle firewall group list List firewall groups (#69)
110
+ huddle firewall group export <name> Export a group as JSON (--out <file>)
111
+ huddle firewall group import <file> Import a group (--replace to mirror)
112
+ huddle firewall group apply <name> Apply a group (--container <id> or global)
113
+ huddle firewall folder set <path> Set the team-managed rules folder
114
+ huddle firewall folder reload Re-read the team-managed rules folder
105
115
  huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
106
116
  and run init
107
117
  huddle experiment reset Back to the stable release
@@ -132,6 +142,8 @@ Migrate options:
132
142
  Firewall options:
133
143
  -i, --interactive Interactively approve/deny (list)
134
144
  --container <name> Filter by (list) / scope to (add) a container
145
+ (or __global__). On import: remap all rules
146
+ to this scope
135
147
  --status <requested|allow|deny> Filter by status (default: requested)
136
148
 
137
149
  Firewall add options:
@@ -140,6 +152,11 @@ Firewall add options:
140
152
  (e.g. /_packaging/*/nuget/v3/*)
141
153
  --deny Create a block rule (default: allow)
142
154
 
155
+ Firewall export/import options:
156
+ --out <file> Write export to a file (default: stdout)
157
+ --replace Import in replace mode: wipe the target
158
+ scope first (default: merge/upsert)
159
+
143
160
  Global options:
144
161
  --url <url> Huddle URL (default: http://localhost:3000)
145
162
  Or via the HUDDLE_URL env var
@@ -202,6 +219,15 @@ async function main() {
202
219
  await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
203
220
  return;
204
221
  }
222
+ if (cmd === 'restart') {
223
+ // Stop + recreate the gateway (runInit does `rm -f` first) so changed team
224
+ // folders get mounted. The portal writes the paths straight into the mounted
225
+ // ~/.huddle/config.json, so runInit already reads the latest values here.
226
+ const initOpts = { runtime: flagString(flags, 'runtime') };
227
+ (0, experiment_1.ensureCliForChannel)(process.argv.slice(2));
228
+ await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
229
+ return;
230
+ }
205
231
  if (cmd === 'experiment') {
206
232
  const subCmd = sub ?? 'status';
207
233
  if (subCmd === 'use') {
@@ -243,6 +269,36 @@ async function main() {
243
269
  container: flagString(flags, 'container'),
244
270
  });
245
271
  }
272
+ else if (subCmd === 'export') {
273
+ await (0, firewall_1.runFirewallExport)({
274
+ container: flagString(flags, 'container'),
275
+ out: flagString(flags, 'out'),
276
+ });
277
+ }
278
+ else if (subCmd === 'import') {
279
+ const file = positional[2];
280
+ if (!file) {
281
+ console.error('Usage: huddle firewall import <file> [--replace] [--container <id>]');
282
+ process.exit(1);
283
+ }
284
+ await (0, firewall_1.runFirewallImport)({
285
+ file,
286
+ replace: flagBool(flags, 'replace'),
287
+ container: flagString(flags, 'container'),
288
+ });
289
+ }
290
+ else if (subCmd === 'group' || subCmd === 'groups') {
291
+ await (0, firewall_1.runFirewallGroup)({
292
+ action: positional[2],
293
+ arg: positional[3],
294
+ out: flagString(flags, 'out'),
295
+ replace: flagBool(flags, 'replace'),
296
+ container: flagString(flags, 'container'),
297
+ });
298
+ }
299
+ else if (subCmd === 'folder') {
300
+ await (0, firewall_1.runFirewallFolder)({ action: positional[2], path: positional[3] });
301
+ }
246
302
  else {
247
303
  console.error(`Unknown firewall subcommand: ${subCmd}`);
248
304
  process.exit(1);
package/dist/init.js CHANGED
@@ -29,12 +29,16 @@ exports.INTERNAL_NET = 'devcontainer-net';
29
29
  */
30
30
  exports.HOST_SOCKET_DIR = '/tmp/dc-sockets';
31
31
  const HOST_PORT = process.env.HUDDLE_PORT ?? '3000';
32
- function run(cmd) {
33
- (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
32
+ // Run a binary with an argv array — NO shell. Values that originate from config
33
+ // (team-folder paths, which are writable via `huddle firewall folder set` and the
34
+ // authenticated settings API) must never be interpolated into a shell string, or
35
+ // a path containing `$()`/quotes would execute on the host. Used for `docker run`.
36
+ function runArgs(file, args) {
37
+ (0, child_process_1.execFileSync)(file, args, { stdio: 'inherit' });
34
38
  }
35
- function runSilent(cmd) {
39
+ function runArgsSilent(file, args) {
36
40
  try {
37
- (0, child_process_1.execSync)(cmd, { stdio: 'ignore' });
41
+ (0, child_process_1.execFileSync)(file, args, { stdio: 'ignore' });
38
42
  return true;
39
43
  }
40
44
  catch {
@@ -52,7 +56,7 @@ function pullBaseImages(rt, images) {
52
56
  for (const image of images) {
53
57
  console.log((0, utils_1.dim)(` Pulling ${image}`));
54
58
  try {
55
- run(`${rt} pull ${image}`);
59
+ runArgs(rt, ['pull', image]);
56
60
  }
57
61
  catch {
58
62
  failed.push(image);
@@ -82,15 +86,15 @@ async function runInit(opts, images) {
82
86
  }
83
87
  else {
84
88
  console.log((0, utils_1.dim)(`Pulling ${IMAGE}`));
85
- run(`${rt} pull ${IMAGE}`);
89
+ runArgs(rt, ['pull', IMAGE]);
86
90
  pullBaseImages(rt, images.baseImages.map((b) => b.image));
87
91
  }
88
92
  console.log((0, utils_1.dim)(`Volume: ${VOLUME}`));
89
- runSilent(`${rt} volume inspect ${VOLUME}`) || run(`${rt} volume create ${VOLUME}`);
93
+ runArgsSilent(rt, ['volume', 'inspect', VOLUME]) || runArgs(rt, ['volume', 'create', VOLUME]);
90
94
  console.log((0, utils_1.dim)(`Network: ${exports.INTERNAL_NET}`));
91
- runSilent(`${rt} network inspect ${exports.INTERNAL_NET}`) || run(`${rt} network create --internal ${exports.INTERNAL_NET}`);
95
+ runArgsSilent(rt, ['network', 'inspect', exports.INTERNAL_NET]) || runArgs(rt, ['network', 'create', '--internal', exports.INTERNAL_NET]);
92
96
  console.log((0, utils_1.dim)(`Removing old container if it exists`));
93
- runSilent(`${rt} rm -f ${CONTAINER}`);
97
+ runArgsSilent(rt, ['rm', '-f', CONTAINER]);
94
98
  console.log((0, utils_1.dim)(`Socket directory: /tmp/dc-sockets`));
95
99
  // The mount SOURCE must be the path on the Docker ENGINE host (on Windows:
96
100
  // the WSL2/Linux VM), even when the CLI itself runs on Windows. The gateway
@@ -105,7 +109,7 @@ async function runInit(opts, images) {
105
109
  // Desktop) and fails with "statfs: no such file or directory". So create
106
110
  // the directory explicitly in the machine VM; the socket lives there too.
107
111
  console.log((0, utils_1.dim)(` (Podman: creating ${hostTmpSockets} in the machine VM)`));
108
- if (!runSilent(`podman machine ssh "mkdir -p ${hostTmpSockets}"`)) {
112
+ if (!runArgsSilent('podman', ['machine', 'ssh', `mkdir -p ${hostTmpSockets}`])) {
109
113
  console.log((0, utils_1.yellow)(`[!] Could not create ${hostTmpSockets} in the Podman VM.`));
110
114
  }
111
115
  }
@@ -126,8 +130,7 @@ async function runInit(opts, images) {
126
130
  // The gateway is engine-agnostic (talks the Docker-compatible API on the
127
131
  // mounted socket), but does need to know it's Podman: it then sets
128
132
  // `--security-opt label=disable` on every devcontainer so it can reach the
129
- // SELinux-labeled proxy socket.
130
- const securityOptFlags = runtime.securityOpts.map((opt) => ` --security-opt ${opt}`).join('');
133
+ // SELinux-labeled proxy socket. (Applied as argv below via runtime.securityOpts.)
131
134
  // Operator token for control-plane auth. Reuse the token from the config (so an
132
135
  // existing browser session/CLI keeps working across re-inits), otherwise
133
136
  // generate one. We pass it to the gateway via env AND store it locally so that
@@ -145,23 +148,41 @@ async function runInit(opts, images) {
145
148
  // network (moby/moby#36174). Which source IP the gateway sees for forwarded
146
149
  // traffic no longer matters — the control plane authenticates with the
147
150
  // operator token instead of source-IP filtering.
148
- run(`${rt} run -d` +
149
- ` --name ${CONTAINER}` +
150
- ` --network ${runtime.defaultNetwork}` +
151
- securityOptFlags +
152
- ` -e HUDDLE_RUNTIME=${runtime.name}` +
153
- ` -e HUDDLE_OPERATOR_TOKEN=${operatorToken}` +
154
- ` -p ${HOST_PORT}:3000` +
155
- ` -v ${VOLUME}:/data` +
156
- ` -v "${runtime.socketPath}:/var/run/docker.sock"` +
157
- ` -v "${hostTmpSockets}:/tmp/dc-sockets"` +
158
- (0, images_1.gatewayEnvFlags)(images) +
159
- ` ${IMAGE}`);
151
+ // Team-managed folders (#69). Bind the CLI config dir (~/.huddle) read-write so
152
+ // the gateway/portal read and write the folder paths there (config.json is the
153
+ // single source of truth), then bind each configured team folder to a FIXED
154
+ // path so the gateway reads it without knowing the host path. Read-only.
155
+ const fwFolder = cfg.firewallRulesFolder?.trim();
156
+ const extFolder = cfg.extensionsFolder?.trim();
157
+ if (fwFolder)
158
+ console.log((0, utils_1.dim)(` Mounting firewall-rules folder: ${fwFolder} -> /firewall-rules`));
159
+ if (extFolder)
160
+ console.log((0, utils_1.dim)(` Mounting extensions folder: ${extFolder} -> /extensions`));
161
+ // Build the container command as an argv array (runArgs → execFileSync, no
162
+ // shell). The folder paths below come from config and are operator-writable via
163
+ // the settings API, so they must never reach a shell as a string.
164
+ const dockerArgs = ['run', '-d', '--name', CONTAINER, '--network', runtime.defaultNetwork];
165
+ for (const opt of runtime.securityOpts)
166
+ dockerArgs.push('--security-opt', opt);
167
+ dockerArgs.push('-e', `HUDDLE_RUNTIME=${runtime.name}`);
168
+ dockerArgs.push('-e', `HUDDLE_OPERATOR_TOKEN=${operatorToken}`);
169
+ dockerArgs.push('-p', `${HOST_PORT}:3000`);
170
+ dockerArgs.push('-v', `${VOLUME}:/data`);
171
+ dockerArgs.push('-v', `${runtime.socketPath}:/var/run/docker.sock`);
172
+ dockerArgs.push('-v', `${hostTmpSockets}:/tmp/dc-sockets`);
173
+ dockerArgs.push('-v', `${config_1.CONFIG_DIR}:/huddle-home:rw`, '-e', 'HUDDLE_HOME_DIR=/huddle-home');
174
+ if (fwFolder)
175
+ dockerArgs.push('-v', `${fwFolder}:/firewall-rules:ro`);
176
+ if (extFolder)
177
+ dockerArgs.push('-v', `${extFolder}:/extensions:ro`);
178
+ dockerArgs.push(...(0, images_1.gatewayEnvArgs)(images));
179
+ dockerArgs.push(IMAGE);
180
+ runArgs(rt, dockerArgs);
160
181
  // Attaching devcontainer-net after the container has started pollutes
161
182
  // resolv.conf on Podman with that network's internal aardvark-DNS; the
162
183
  // gateway cleans that up itself (see dns-egress.ts / the startup sanitize in
163
184
  // index.ts).
164
- runSilent(`${rt} network connect ${exports.INTERNAL_NET} ${CONTAINER}`);
185
+ runArgsSilent(rt, ['network', 'connect', exports.INTERNAL_NET, CONTAINER]);
165
186
  console.log();
166
187
  console.log((0, utils_1.green)(`[OK] Huddle is running at http://localhost:${HOST_PORT}`));
167
188
  console.log();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosupport/huddle-cli",
3
- "version": "0.0.0-experiment-97.41.1",
3
+ "version": "0.0.0-experiment-98.44.1",
4
4
  "description": "Huddle CLI — start devcontainers and manage firewall rules",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "author": "Info Support B.V.",