Skip to content

Commit 2cb59f4

Browse files
committed
Only allow user packages on system VFS (#28)
1 parent af11565 commit 2cb59f4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/packages.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
const fs = require('fs-extra');
3232
const fg = require('fast-glob');
3333
const path = require('path');
34-
const Package = require('./package.js');
3534
const consola = require('consola');
35+
const Package = require('./package.js');
36+
const {getPrefix} = require('./utils/vfs.js');
3637
const logger = consola.withTag('Packages');
3738

3839
const relative = filename => filename.replace(process.cwd(), '');
@@ -155,11 +156,17 @@ class Packages {
155156
* @return {Package[]} List of packages
156157
*/
157158
async readPackageManifests(paths, user) {
158-
const {realpath} = this.core.make('osjs/vfs');
159+
const {realpath, mountpoints} = this.core.make('osjs/vfs');
159160
const {manifestFile} = this.options;
160161
const systemManifest = await readOrDefault(manifestFile);
161162

162-
const userManifests = await Promise.all(paths.map(async p => {
163+
const isValidVfs = p => {
164+
const prefix = getPrefix(p);
165+
const mount = mountpoints.find(m => m.name === prefix);
166+
return mount && mount.attributes.root;
167+
};
168+
169+
const userManifests = await Promise.all(paths.filter(isValidVfs).map(async p => {
163170
const real = await realpath(`${p}/metadata.json`, user);
164171
const list = await readOrDefault(real);
165172

0 commit comments

Comments
 (0)