@danieltmn/tamnora 0.21.0 → 0.21.2
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/CHANGELOG.md +12 -0
- package/README.md +10 -6
- package/SECURITY.md +13 -0
- package/harness/packages/cli/src/cli.js +3 -0
- package/harness/packages/cli/src/commands/config.js +141 -0
- package/harness/packages/core/src/browser/index.js +56 -2
- package/harness/packages/core/src/config/portable.js +138 -0
- package/harness/packages/core/src/hooks/index.js +9 -5
- package/harness/packages/core/src/index.js +1 -0
- package/harness/packages/core/src/net/hosts.js +111 -0
- package/harness/packages/core/src/plugins/index.js +6 -4
- package/harness/packages/core/src/tools/executors.js +42 -36
- package/harness/packages/core/test/hooks.test.js +6 -3
- package/harness/packages/core/test/hosts.test.js +50 -0
- package/harness/packages/core/test/plugins.test.js +5 -3
- package/harness/packages/core/test/portable.test.js +150 -0
- package/harness/packages/core/test/tools.test.js +54 -1
- package/harness/packages/server/public/app.js +33 -8
- package/harness/packages/server/public/index.html +1 -1
- package/harness/packages/server/public/styles.css +4 -0
- package/harness/packages/server/src/lib/procs.js +30 -3
- package/harness/packages/server/src/routes/procs.js +2 -6
- package/harness/packages/server/src/server.js +9 -2
- package/harness/packages/server/test/procs-manager.test.js +43 -0
- package/harness/packages/server/test/server.test.js +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdtemp } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { createProcManager } from '../src/lib/procs.js';
|
|
7
|
+
|
|
8
|
+
async function workspace() {
|
|
9
|
+
return mkdtemp(path.join(tmpdir(), 'tamnora-procs-'));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
test('procs rechaza binarios fuera de la allowlist y args invalidos', async () => {
|
|
13
|
+
const cwd = await workspace();
|
|
14
|
+
const procs = createProcManager({ allow: ['node'] });
|
|
15
|
+
assert.throws(() => procs.start({ cwd, command: 'calc' }), /no permitido/);
|
|
16
|
+
assert.throws(() => procs.start({ cwd, command: 'node', args: 'x' }), /lista de strings/);
|
|
17
|
+
assert.throws(() => procs.start({ cwd, command: 'node', args: ['a\0b'] }), /Argumento inválido/);
|
|
18
|
+
assert.throws(
|
|
19
|
+
() => procs.start({ cwd, command: 'node', args: Array.from({ length: 33 }, () => 'x') }),
|
|
20
|
+
/Demasiados argumentos/
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('en Windows los args no admiten metacaracteres del shell', { skip: process.platform !== 'win32' }, async () => {
|
|
25
|
+
const cwd = await workspace();
|
|
26
|
+
const procs = createProcManager({ allow: ['npm', 'node'] });
|
|
27
|
+
for (const arg of ['x & calc', 'x | calc', 'x > out.txt', 'x %PATH%', 'x^y', 'x"y']) {
|
|
28
|
+
assert.throws(() => procs.start({ cwd, command: 'npm', args: ['run', arg] }), /Argumento no permitido/);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('procs arranca y detiene un proceso permitido', async () => {
|
|
33
|
+
const cwd = await workspace();
|
|
34
|
+
const procs = createProcManager({ allow: ['node'] });
|
|
35
|
+
const proc = procs.start({ cwd, command: process.execPath, args: ['-e', 'setTimeout(() => {}, 5000)'] });
|
|
36
|
+
try {
|
|
37
|
+
assert.ok(proc.id);
|
|
38
|
+
assert.equal(proc.running, true);
|
|
39
|
+
assert.equal(procs.list().length, 1);
|
|
40
|
+
} finally {
|
|
41
|
+
assert.equal(procs.stop(proc.id), true);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -1578,7 +1578,14 @@ test('hooks observe tool events and plugins add custom tools', async () => {
|
|
|
1578
1578
|
path.join(cwd, '.tamnora', 'plugins', 'demo.mjs'),
|
|
1579
1579
|
"export default { name: 'demo', tools: [{ name: 'saludar', description: 'saluda', parameters: { quien: { type: 'string' } }, handler: (args) => `Hola ${args.quien}` }] };\n"
|
|
1580
1580
|
);
|
|
1581
|
-
await writeFile(
|
|
1581
|
+
await writeFile(
|
|
1582
|
+
path.join(cwd, 'tamnora.json'),
|
|
1583
|
+
JSON.stringify({
|
|
1584
|
+
hooks: ['.tamnora/hooks/*.mjs'],
|
|
1585
|
+
plugins: ['.tamnora/plugins/*.mjs'],
|
|
1586
|
+
permissions: { plugin__demo__saludar: 'allow' },
|
|
1587
|
+
})
|
|
1588
|
+
);
|
|
1582
1589
|
|
|
1583
1590
|
let captured = null;
|
|
1584
1591
|
const provider = {
|
package/package.json
CHANGED