unbound-cli 1.26.0 → 1.26.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unbound-cli",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
4
4
  "description": "CLI tool for Unbound - AI Gateway management",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -520,6 +520,10 @@ Examples:
520
520
  }
521
521
  fs.mkdirSync(opts.out, { recursive: true });
522
522
  for (const name of [...packs.keys()].sort((a, b) => a.localeCompare(b))) {
523
+ if (!SLUG_RE.test(name)) {
524
+ output.warn(`pack "${name}": not a valid pack name, no file written.`);
525
+ continue;
526
+ }
523
527
  const { live, version, owner } = await fetchStablePack(name);
524
528
  for (const { row } of live.unsupported) output.warn(`${row.name}: unsupported policy type, not exported.`);
525
529
  if (!live.tool.length && !live.generic.length) {
@@ -432,3 +432,31 @@ test('adopt keeps the stored owner in the apply and generated pack', async () =>
432
432
  fs.rmSync(home, { recursive: true, force: true });
433
433
  }
434
434
  });
435
+
436
+ test('pack export --all skips a pack name that would write outside the folder', async () => {
437
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'pack-export-'));
438
+ const out = path.join(home, 'out');
439
+ const server = http.createServer((req, res) => {
440
+ const send = (body) => {
441
+ res.writeHead(200, { 'Content-Type': 'application/json' });
442
+ res.end(JSON.stringify(body));
443
+ };
444
+ if (req.url.startsWith('/api/v1/policies/form_data/')) return send({ data: {} });
445
+ if (req.url.startsWith('/api/v1/labels/')) return send({ labels: [] });
446
+ if (req.url.startsWith('/api/v1/command-policies/')) {
447
+ return send({ policies: [{ id: '1', name: 'x', policy_type: 'MCP_TOOL', origin: 'CODE', code_pack: '../escape', code_slug: 'x' }], total_pages: 1 });
448
+ }
449
+ return send({ policies: [] });
450
+ });
451
+ try {
452
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
453
+ const result = await runCli(null, server.address().port, home, ['export', '--all', '-o', out]);
454
+ assert.equal(result.code, 0, result.stderr);
455
+ assert.match(result.stdout + result.stderr, /not a valid pack name/);
456
+ assert.equal(fs.existsSync(path.join(home, 'escape.yaml')), false);
457
+ assert.deepEqual(fs.readdirSync(out), []);
458
+ } finally {
459
+ server.close();
460
+ fs.rmSync(home, { recursive: true, force: true });
461
+ }
462
+ });