fix(plugins): restrict child runtime modules

Plugins access their storage through the scoped database API.
This commit is contained in:
Maurice
2026-11-30 22:06:07 +01:00
parent c0b28dd4da
commit 75cc0a4de2
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -182,6 +182,8 @@ export function pluginPermissionArgs(pluginId: string): string[] {
const codeRoot = serverCodeRoot();
return [
'--permission',
// Built-in SQLite is outside Node's filesystem allowlist. Plugins use ctx.db.
'--no-experimental-sqlite',
`--allow-fs-read=${codeRoot}`,
// The server package.json sits one level above dist and Node reads it to
// resolve the child's module type. Grant just that file — never its dir,
@@ -82,6 +82,7 @@ describe('paths', () => {
delete process.env.TREK_PLUGIN_PERMISSIONS;
const args = pluginPermissionArgs('flight-tracker');
expect(args).toContain('--permission');
expect(args).toContain('--no-experimental-sqlite');
// read is scoped to the compiled server dir + this plugin's own code dir…
expect(args.some((a) => a === `--allow-fs-read=${serverCodeRoot()}`)).toBe(true);
expect(args.some((a) => a === `--allow-fs-read=${pluginCodeDir('flight-tracker')}`)).toBe(true);